【发布时间】:2017-10-03 08:37:01
【问题描述】:
我在 Agular2 项目中使用 ADAL 库针对 Azure AD 对用户进行身份验证,一旦用户通过身份验证调用 WebAPI 以使用 REST 调用获取一些信息。所有这些都适用于 AngularJS-AzureAD-WebAPI 场景。
按照MS文章创建示例项目https://blogs.msdn.microsoft.com/premier_developer/2017/04/26/using-adal-with-angular2
WebAPI 接收来自 Angular2 项目的调用,但请求具有匿名的授权令牌。经过进一步研究,发现 JWT 缺少 appid 值,并且 aud 属性包含 GUID,即应用程序 ID。
工作调用 JWT:(AngularJS 到 WebAPI)
appid:在 Azure 中注册的本机应用程序的 GUID
aud:someone.onmicrosoft.com/CortanaWebAPI
不工作调用 JWT:(Angular2 到 webAPI)
appid:此属性没有条目
aud:在 Azure 中注册的本机应用程序的 GUID
adal 配置
const endpoints = {
“https://localhost:44383/”: “http://someone.onmicrosoft.com/CortanaWebAPI”
};
public get getAdalConfig(): any {
return {
tenant: ‘someone.onmicrosoft.com’,
clientId: ‘9d9cd8dd-087a-4e87-b3f9-6e7ded2b5e82’,
redirectUri: window.location.origin + ‘/’,
postLogoutRedirectUri: window.location.origin + ‘/’,
endpoints: endpoints
};
}
不知道为什么会这样,感谢任何帮助。
【问题讨论】:
标签: angular azure angular2-services adal