Skip to content

Commit 822ec36

Browse files
author
John Luo
committed
Fix AzureAd options validation
1 parent 8e52f69 commit 822ec36

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public AzureADOpenIdConnectOptionsConfiguration(IOptions<AzureADSchemeOptions> s
2121
public void Configure(string name, OpenIdConnectOptions options)
2222
{
2323
var azureADScheme = GetAzureADScheme(name);
24+
if (azureADScheme is null)
25+
{
26+
return;
27+
}
28+
2429
var azureADOptions = _azureADOptions.Get(azureADScheme);
2530
if (name != azureADOptions.OpenIdConnectSchemeName)
2631
{

src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,5 +485,25 @@ public void AddAzureADBearer_SkipsOptionsValidationForNonAzureCookies()
485485

486486
Assert.NotNull(jwtOptions.Get("other"));
487487
}
488+
489+
[Fact]
490+
public void AddAzureAD_SkipsOptionsValidationForNonAzureOpenIdConnect()
491+
{
492+
var services = new ServiceCollection();
493+
services.AddSingleton<ILoggerFactory>(new NullLoggerFactory());
494+
495+
services.AddAuthentication()
496+
.AddAzureAD(o => { })
497+
.AddOpenIdConnect("other", null, o =>
498+
{
499+
o.ClientId = "ClientId";
500+
o.Authority = "https://authority.com";
501+
});
502+
503+
var provider = services.BuildServiceProvider();
504+
var openIdConnectOptions = provider.GetService<IOptionsMonitor<OpenIdConnectOptions>>();
505+
506+
Assert.NotNull(openIdConnectOptions.Get("other"));
507+
}
488508
}
489509
}

0 commit comments

Comments
 (0)