From be0ea5c093fcdf112b8f11f86784006017a85811 Mon Sep 17 00:00:00 2001 From: Bogdan Gavril Date: Mon, 13 May 2024 12:23:32 +0100 Subject: [PATCH] Fix for #4608- do not throw exception for ADFS + WithTenantId (#4753) Fix for #2509 - do not throw exception for ADFS + WithTenantId --- .../BaseAbstractApplicationBuilder.cs | 8 ------ .../ApiConfigTests/AuthorityTests.cs | 28 ------------------- 2 files changed, 36 deletions(-) diff --git a/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs b/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs index 33c9cfeee3..e947a6d2cb 100644 --- a/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs +++ b/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs @@ -132,7 +132,6 @@ internal T WithHttpManager(IHttpManager httpManager) /// If both WithLogging apis are set, this one will override the other /// /// The builder to chain the .With methods - /// This is an experimental API. The method signature may change in the future without involving a major version upgrade. public T WithLogging( IIdentityLogger identityLogger, bool enablePiiLogging = false) @@ -218,13 +217,6 @@ internal void ResolveAuthority() // Both WithAuthority and WithTenant were used at app config level if (!string.IsNullOrEmpty(Config.TenantId)) { - if (!Config.Authority.AuthorityInfo.CanBeTenanted) - { - throw new MsalClientException( - MsalError.TenantOverrideNonAad, - $"Cannot use WithTenantId(tenantId) in the application builder, because the authority {Config.Authority.AuthorityInfo.AuthorityType} doesn't support it."); - } - string tenantedAuthority = Config.Authority.GetTenantedAuthority( Config.TenantId, forceSpecifiedTenant: true); diff --git a/tests/Microsoft.Identity.Test.Unit/ApiConfigTests/AuthorityTests.cs b/tests/Microsoft.Identity.Test.Unit/ApiConfigTests/AuthorityTests.cs index 4a881bcadc..2b4113ae1c 100644 --- a/tests/Microsoft.Identity.Test.Unit/ApiConfigTests/AuthorityTests.cs +++ b/tests/Microsoft.Identity.Test.Unit/ApiConfigTests/AuthorityTests.cs @@ -175,34 +175,6 @@ public void B2CAuthorityWithTenantAppLevel() AuthorityHelpers.GetTenantId(new Uri(cca.Authority))); } - [TestMethod] - public void GenericAuthorityWithTenant() - { - var ex = AssertException.Throws(() => - ConfidentialClientApplicationBuilder - .Create(TestConstants.ClientId) - .WithTenantId(TestConstants.TenantId2) - .WithOidcAuthority(TestConstants.GenericAuthority) - .Build() - ); - - Assert.AreEqual(ex.ErrorCode, MsalError.TenantOverrideNonAad); - } - - [TestMethod] - public void AdfsAuthorityWithTenant() - { - var ex = AssertException.Throws(() => - ConfidentialClientApplicationBuilder - .Create(TestConstants.ClientId) - .WithTenantId(TestConstants.TenantId2) - .WithAuthority(TestConstants.ADFSAuthority) - .Build() - ); - - Assert.AreEqual(ex.ErrorCode, MsalError.TenantOverrideNonAad); - } - [TestMethod] public void WithTenantId_B2C() {