Fix AzureAd options validation (#23096)
This commit is contained in:
parent
4db94ff4da
commit
d45e6b25f4
|
|
@ -21,6 +21,11 @@ namespace Microsoft.AspNetCore.Authentication.AzureAD.UI
|
||||||
public void Configure(string name, OpenIdConnectOptions options)
|
public void Configure(string name, OpenIdConnectOptions options)
|
||||||
{
|
{
|
||||||
var azureADScheme = GetAzureADScheme(name);
|
var azureADScheme = GetAzureADScheme(name);
|
||||||
|
if (azureADScheme is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var azureADOptions = _azureADOptions.Get(azureADScheme);
|
var azureADOptions = _azureADOptions.Get(azureADScheme);
|
||||||
if (name != azureADOptions.OpenIdConnectSchemeName)
|
if (name != azureADOptions.OpenIdConnectSchemeName)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -485,5 +485,25 @@ namespace Microsoft.AspNetCore.Authentication
|
||||||
|
|
||||||
Assert.NotNull(jwtOptions.Get("other"));
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue