简体   繁体   English

对于使用 Angular SPA 获取的 Active Directory B2C JWT 令牌,acr 声明为 null

[英]acr claim is null for the Active Directory B2C JWT token acquired using Angular SPA

I downloaded here from GITHUB an Azure Sample for using Azure Active Directory B2C (ADB2C) in Angular. I downloaded here from GITHUB an Azure Sample for using Azure Active Directory B2C (ADB2C) in Angular. Please consider that ADB2C on Azure Portal has been successfully configured by me and is able to interact with my Angular application.请考虑我已成功配置 Azure 门户上的 ADB2C,并且能够与我的 Angular 应用程序交互。 Infact I'm happily able to sign-up a new user without problem.事实上,我很高兴能够毫无问题地注册一个新用户。
But, once I signin, it always returns the following message:但是,一旦我登录,它总是返回以下消息:

Password has been reset successfully.密码已成功重置。 Please sign-in with your new password请使用您的新密码登录

I tryied to reset the password, but I always receive the same.我尝试重置密码,但我总是收到相同的密码。 I inspected the Microsoft Code and I discovered this line:我检查了Microsoft 代码,发现了这一行:

  if (success.idToken.claims['acr'] !== b2cPolicies.names.signUpSignIn) {
    window.alert("Password has been reset successfully. \nPlease sign-in with your new password");
    return this.authService.logout()
  }

I investigated a little bit further and I realized that the generated ADB2C JWTToken is missing the "acr" claim.我进一步调查了一下,我意识到生成的 ADB2C JWTToken 缺少“acr”声明。 And here , on Microsoft Official Documentation, they wrote: 在这里,在微软官方文档中,他们写道:

Used only with older policies.仅与旧策略一起使用。 So I'm wondering:所以我想知道:

  1. Is "acr" claim mandatory? “acr”声明是强制性的吗?
  2. Can I comment out the line without affecting the stability?我可以在不影响稳定性的情况下注释掉该行吗? The application seems work and the returned JWT is well formed该应用程序似乎可以正常工作,并且返回的 JWT 格式正确
  3. Why the GitHub code is using this weired condition?为什么 GitHub 代码使用这种奇怪的条件? I will open an issue than..我将打开一个问题而不是..

Thanks谢谢

Got it sorted out.搞定了I quote the answer that Derisen (the author) reply to me here on GitHub:我引用 Derisen(作者)在 GitHub 上回复我答案:

  1. acr claim is only required if you need to use password reset flow.仅当您需要使用密码重置流程时才需要acr声明。 For newer policies, its equivalent is tfp (let me know if you don't have that claim in your token).对于较新的政策,它的等价物是tfp (如果您的令牌中没有该声明,请告诉我)。
  2. you can certainly do that, if you don't need password reset flow.如果您不需要密码重置流程,您当然可以这样做。

And I realized that on Azure Portal, in the ADB2C section, you can change the setting:我意识到在 Azure 门户上,在 ADB2C 部分,您可以更改设置:

在此处输入图像描述

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

相关问题 Angular 4 / Angular 2针对Azure B2C Active Directory验证SPA - Angular 4/Angular 2 validate SPA against Azure B2C Active Directory Angular Azure Active Directory B2C 身份验证 - CORS 问题 - Angular Azure Active Directory B2C Authentication - CORS issue Angular 2 SPA Azure Active Directory JWT问题 - Angular 2 SPA Azure Active Directory JWT Issue Azure B2C Authentication (angular + .net core Web API) - Neither scope or roles claim was found in the bearer token - Azure B2C Authentication (angular + .net core Web API) - Neither scope or roles claim was found in the bearer token 使用Azure AD B2C时向Angular SPA和MSAL添加角色 - Adding roles to Angular SPA and MSAL when using using Azure AD B2C 使用B2C在Javascript / Angular 6 SPA应用程序中通过MSAL.JS注销的错误 - Error in Logout through MSAL.JS in Javascript / Angular 6 SPA application using B2C Azure B2C 访问令牌验证和自定义 JWT 令牌生成 - Azure B2C access token validation and custom JWT token generation 使用 Angular SPA MSAL 库在 Azure B2C 上执行用户流程 - Execute user flow on Azure B2C with Angular SPA MSAL library 向Angular 4 SPA请求Web API时,范围声明为空 - Scope claim is null when requesting web api from Angular 4 SPA 在 NativeScript angular 应用程序中使用 Azure AD B2C 进行身份验证 - Authenticate using Azure AD B2C in a NativeScript angular Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM