繁体   English   中英

Azure AD B2C oauth / OpenIdConnect问题

[英]Issue with Azure AD B2C oauth/OpenIdConnect

我对azure身份验证有一个奇怪的问题。 它适用于一种情况(使用adal登录角度应用程序)但不能在其他情况下登录(加载asp.net web api并通过swagger ui authorize机制登录)。 我把它缩小到了一个帖子:

https://login.microsoftonline.com/te/{tenantid}/oauth2/authresp

无效返回的端点:

302

<html>
 <head>
  <title>Object moved</title></head>
  <body>
   <h2>Object moved to <a href="http://localhost:49919/swagger/ui/oauth2redirect-html#error=server_error&amp;error_description=AADB2C%3a+An+exception+has+occured.%0d%0aCorrelation+ID%3a+1816d2f8-aa74-4433-a7c0-d9c8fabebdb0%0d%0aTimestamp%3a+2017-10-27+13%3a46%3a08Z%0d%0a&amp;state={ommitted}">here</a>.</h2>
</body>
</html>

基本上告诉我发生了异常。

error_description = AADB2C发生了异常。

CorrelationID = 1816d2f8-aa74-4433-a7c0-d9c8fabebdb0

时间戳= 2017-10-27 13:46:08

角度应用程序,完全相同的帖子,但然而返回带有令牌ID的链接:

302

<html>
  <head>
   <title>Object moved</title>
  </head>
  <body>
   <h2>Object moved to <a href="http://localhost:4200/#state={state -
   ommitted}&amp;id_token={id token - omitted}">here</a>.
    </h2>
   </body>
 </html>

我看不出帖子有什么不同。 这个不起作用(从web api项目的swagger ui发起)

POST https://login.microsoftonline.com/te/{tenant - omitted}/oauth2/authresp HTTP/1.1
Host: login.microsoftonline.com
Connection: keep-alive
Content-Length: 1595
Cache-Control: max-age=0
Origin: https://login.microsoftonline.com
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Referer: https://login.microsoftonline.com/{tenant - omitted}/oauth2/authorize?client_id={clientid - omitted}&redirect_uri=https:%2f%2flogin.microsoftonline.com%2fte%2f{tenant - omitted}%2foauth2%2fauthresp&response_type=id_token&response_mode=form_post&nonce={nonce}&state=StateProperties
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en;q=0.9,de-CH;q=0.8,de;q=0.7,fr-CH;q=0.6,fr;q=0.5,it-CH;q=0.4,it;q=0.3
Cookie: {cookie - omitted}=; x-ms-gateway-slice=005; stsservicecookie=cpim_te

id_token={omitted}

但这篇文章的确如下:

POST https://login.microsoftonline.com/te/{tenant - omitted}/oauth2/authresp HTTP/1.1
Host: login.microsoftonline.com
Connection: keep-alive
Content-Length: 1590
Cache-Control: max-age=0
Origin: https://login.microsoftonline.com
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Referer: https://login.microsoftonline.com/{tenant - omitted}/oauth2/authorize?client_id={clientid - omitted}&redirect_uri=https:%2f%2flogin.microsoftonline.com%2fte%2f{tenant - omitted}%2foauth2%2fauthresp&response_type=id_token&response_mode=form_post&nonce={nonce}&state=StateProperties
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en;q=0.9,de-CH;q=0.8,de;q=0.7,fr-CH;q=0.6,fr;q=0.5,it-CH;q=0.4,it;q=0.3
Cookie: {cookie - omitted}; x-ms-gateway-slice=003; stsservicecookie=cpim_te

id_token={omitted}

由于帖子非常相同,因此问题必须存在于cookie或id令牌中(出于安全原因我无法提供)。 将来自两个请求的ID令牌粘贴到http://www.jwt.io中 ,可以获得与两者中存在的正确声明相同的信息。 所以我有点卡住了,希望天蓝队的人能介入并帮忙吗?

非常感谢

根据您的请求示例中的引荐来源,您似乎没有调用/v2.0/ B2C端点。 例如,在以下请求中,路径应为/ {tenant} / oauth2 / v2.0 / authorize ...

https://login.microsoftonline.com/{tenant}/oauth2/authorize?client_id={clientid}&redirect_uri=https:%2f%2flogin.microsoftonline.com%2fte%2f{tenant}%2foauth2%2fauthresp&response_type=id_token&response_mode=form_post&nonce={nonce}&state=StateProperties

因此,您在两个应用中都会遇到意外行为。 这也意味着您使用的应用程序不是使用B2C门户创建的(我们也通过我们的离线聊天进行了验证)。

截至目前,B2C仅支持通过B2C门户创建的应用程序。 因此,如果您可以通过B2C门户创建应用程序,然后再试一次,则应该解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM