Azure AD ADAL隐式流程说明

时间:2018-12-11 22:59:16

标签: oauth-2.0 azure-active-directory oidc

想知道是否有人可以帮我澄清一下
我正在使用ADAL js通过隐式流登录angular7应用程序。 通过发送response_type = id_token起作用 这种响应类型的结果是命中了Authorization端点,我应该找回一个ID令牌 ID_TOKEN

但是我似乎重新获得了承载令牌,Azure microsoft登录名将我重定向到http://localhost:4200/#access_token=xxxxxxxx &token_type = Bearer

我期望返回的令牌是ID令牌而不是承载令牌,当我调用后端API时,它的行为确实像承载令牌。

ADAL.js似乎没有让我请求“ id_token令牌”,如下所示: ID_TOKEN TOKEN

对不起,我开始阅读规格书,因为它混淆了我对正在运行的应用程序的理解,但是如果有人可以稍微了解一下Azure对其隐式流程的实际作用,我肯定会感到高兴,它仅提及id_token在文档中,并且不引用“ id_token令牌”响应类型

如果有的话,Azure AD似乎与reponse_type = token更加内联 Token

tnx, 布莱恩

1 个答案:

答案 0 :(得分:1)

Azure AD V2.0端点

Microsoft文档: v2.0 Protocols - SPAs using the implicit flow

它显然提到了OpenId Connect

  • 请求必须包含response_type=id_token(您已经在发送)
  • scope=openid可能丢失了,并在使用MSAL库实现流程后解决了(如@brianbruff在评论中所述)。
  • 此外,应启用“允许隐式流程”进行App注册。

enter image description here enter image description here enter image description here

来自文档的示例请求

// Line breaks for legibility only

https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=id_token
&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
&scope=openid
&response_mode=fragment
&state=12345
&nonce=678910

Azure AD V1.0端点

Microsoft文档:Understanding the OAuth2 implicit grant flow in Azure Active Directory (AD)

即使在这里,文档也清楚地表明,使用OpenID Connect时可以获取id_token。

enter image description here

但是我必须说,在v1.0隐式授权流程的情况下,我不确定是否完全建议/正确实现ID_token。 (至少@brianbruff能够使用v2.0并解决他的问题。)

我看到另一个Microsoft Docs link for OpenID connect with v1.0(但不是隐式授权流)提到了scope=openid的用法。虽然,在此页面的底部,我看到了一些未解决的问题,在这些问题上,用户在某种程度上与文档相矛盾,并且专门针对“隐式授权”流程提供了反馈。

enter image description here

Issue 17140

Issue 19382