diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs index a991620aae3200ed916abe68c433abf32e4e7e97..9b5be26438fa20d8a5c0ab45a2fa969c91279023 100644 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs +++ b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs @@ -21,6 +21,11 @@ namespace Microsoft.AspNetCore.Authentication.AzureAD.UI public void Configure(string name, OpenIdConnectOptions options) { var azureADScheme = GetAzureADScheme(name); + if (azureADScheme is null) + { + return; + } + var azureADOptions = _azureADOptions.Get(azureADScheme); if (name != azureADOptions.OpenIdConnectSchemeName) { diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs index 07c0583c32b769160cf7cee22dbac1ef18a5419a..6a31d3477ec2bd4cf676cc0cb8ff007dda416527 100644 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs +++ b/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs @@ -485,5 +485,25 @@ namespace Microsoft.AspNetCore.Authentication Assert.NotNull(jwtOptions.Get("other")); } + + [Fact] + public void AddAzureAD_SkipsOptionsValidationForNonAzureOpenIdConnect() + { + var services = new ServiceCollection(); + services.AddSingleton<ILoggerFactory>(new NullLoggerFactory()); + + services.AddAuthentication() + .AddAzureAD(o => { }) + .AddOpenIdConnect("other", null, o => + { + o.ClientId = "ClientId"; + o.Authority = "https://authority.com"; + }); + + var provider = services.BuildServiceProvider(); + var openIdConnectOptions = provider.GetService<IOptionsMonitor<OpenIdConnectOptions>>(); + + Assert.NotNull(openIdConnectOptions.Get("other")); + } } }