我们正在从Windows身份验证迁移到Azure AD。
我们有这样的政策:
services.AddAuthorization(options =>
{
options.AddPolicy("Test", policy => policy.RequireClaim(ClaimTypes.Role, "Test"));
});
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => this.Configuration.Bind("AzureAd", options))
.AddCookie();
我的控制器装饰有
[Authorize(Policy = "Test")]
这是清单json:
"appRoles": [
{
"allowedMemberTypes": [
"User"
],
"description": "Security group for Test.",
"displayName": "Test",
"id": "5500dd65-c64b-400e-98dd-8e255563aefe",
"isEnabled": true,
"lang": null,
"origin": "Application",
"value": "Test"
}
],
我们从azure门户为此应用角色分配了有效的组。
在我的本地环境上工作完美,但是将其部署到开发环境后,我们又退回Forbidden
进行授权。
检查日志,我们发现如下所示:
AuthenticationScheme: AzureADCookie was not authenticated.
AuthenticationScheme: AzureADCookie was forbidden.
Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
对于所有阅读本文的人-预先感谢!
答案 0 :(得分:1)
最后,我发现了问题:代码没有错...
我们当前正在使用Windows身份验证。
从Windows身份验证迁移到Azure AD身份验证并将代码更改发布到我们的Dev环境之后,我们需要更改Dev服务器上的IIS配置: 到: