Skip to content
代码片段 群组 项目
未验证 提交 d45e6b25 编辑于 作者: John Luo's avatar John Luo 提交者: GitHub
浏览文件

Fix AzureAd options validation (#23096)

上级 4db94ff4
No related branches found
No related tags found
无相关合并请求
...@@ -21,6 +21,11 @@ namespace Microsoft.AspNetCore.Authentication.AzureAD.UI ...@@ -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 ...@@ -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"));
}
} }
} }
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册