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

Fix AzureAd options validation (#13480)

* Skip getting AzureAdOptions for not AzureADUi Cookies scheme #13311 (#13327)

* Also check Azure Jwt options for #13311
上级 ecae6838
No related branches found
No related tags found
无相关合并请求
......@@ -21,6 +21,11 @@ namespace Microsoft.AspNetCore.Authentication.AzureAD.UI
public void Configure(string name, CookieAuthenticationOptions options)
{
var AzureADScheme = GetAzureADScheme(name);
if (AzureADScheme is null)
{
return;
}
var AzureADOptions = _AzureADOptions.Get(AzureADScheme);
if (name != AzureADOptions.CookieSchemeName)
{
......
......@@ -24,6 +24,11 @@ namespace Microsoft.AspNetCore.Authentication
public void Configure(string name, JwtBearerOptions options)
{
var azureADScheme = GetAzureADScheme(name);
if (azureADScheme is null)
{
return;
}
var azureADOptions = _azureADOptions.Get(azureADScheme);
if (name != azureADOptions.JwtBearerSchemeName)
{
......
......@@ -268,6 +268,22 @@ namespace Microsoft.AspNetCore.Authentication
Assert.Contains(expectedMessage, exception.Failures);
}
[Fact]
public void AddAzureAD_SkipsOptionsValidationForNonAzureCookies()
{
var services = new ServiceCollection();
services.AddSingleton<ILoggerFactory>(new NullLoggerFactory());
services.AddAuthentication()
.AddAzureAD(o => { })
.AddCookie("other");
var provider = services.BuildServiceProvider();
var cookieAuthOptions = provider.GetService<IOptionsMonitor<CookieAuthenticationOptions>>();
Assert.NotNull(cookieAuthOptions.Get("other"));
}
[Fact]
public void AddAzureADBearer_AddsAllAuthenticationHandlers()
{
......@@ -453,5 +469,21 @@ namespace Microsoft.AspNetCore.Authentication
Assert.Contains(expectedMessage, exception.Failures);
}
[Fact]
public void AddAzureADBearer_SkipsOptionsValidationForNonAzureCookies()
{
var services = new ServiceCollection();
services.AddSingleton<ILoggerFactory>(new NullLoggerFactory());
services.AddAuthentication()
.AddAzureADBearer(o => { })
.AddJwtBearer("other", o => { });
var provider = services.BuildServiceProvider();
var jwtOptions = provider.GetService<IOptionsMonitor<JwtBearerOptions>>();
Assert.NotNull(jwtOptions.Get("other"));
}
}
}
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册