【发布时间】:2019-08-22 17:08:25
【问题描述】:
我正在使用 Angular 7 开发标准 .NET Web Api 2,我需要连接 Azure Active Directory。
我已添加此代码:
public static void ConfigureAuth(IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = configurationManager.AadTenant,
TokenValidationParameters = new TokenValidationParameters
{
ValidAudience = configurationManager.AadAudience,
},
});
}
我的租户和观众都是正确的。一切正常,令牌有效并存在于请求中。
问题是 IsAuthenticated 总是假的,当我在身份中查看声明时,它们是空的
protected override bool IsAuthorized(HttpActionContext actionContext)
{
return base.IsAuthorized(actionContext); // Always false
}
我不知道问题出在哪里。我尝试了很多链接,但没有一个对我有用。有人知道为什么吗?谢谢
【问题讨论】:
标签: azure authentication asp.net-web-api azure-active-directory