对于我的Azure B2C用户流,我使用B2C属性。用户使用角形应用程序登录,我在前端得到这个属性/声明。另外,我还获得了一个访问令牌,它用作承载访问ASP.NET Core3.1WebAPI的载体。
这就是问题所在--当用户是本地用户(电子邮件注册)时,访问令牌工作(包含UserIsNew声明)。但是当它是一个外部用户(在我的例子中是微软帐户)时,我只在这个角度的应用程序中得到了这个声明。访问令牌没有自定义属性,因此web返回拒绝访问!
我遗漏了什么?
更新
以下是我在“角”应用程序中得到的声明:

它们来自服务器端(web ):
"claims": [
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "exp",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "nbf",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "aud",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "idp"
},
"type": "http://schemas.microsoft.com/identity/claims/identityprovider",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "name",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "oid"
},
"type": "http://schemas.microsoft.com/identity/claims/objectidentifier",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "sub"
},
"type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "given_name"
},
"type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "family_name"
},
"type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "emails",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "tfp",
"value": "B2C_1_susi",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "nonce",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "scp"
},
"type": "http://schemas.microsoft.com/identity/claims/scope",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "azp",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "ver",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "iat",
}
],newUser失踪了。
更新1
这些是已使用的flow用户属性设置:

这是建立起来的:

另外,请记住-我正在测试用户注册时的场景,所以每次都需要 UserIsNew 。
发布于 2020-06-30 17:42:54
之所以没有在令牌中返回(显示名称、电子邮件地址、职务名称、PhoneNumber、邮政编码)声明,是因为用户被添加为外部(来宾)用户。用户没有完成注册过程,也没有收集这些属性的值。没有值的属性不会在令牌中返回。
一旦我们注册了一个新的用户帐户并为这些属性提供了值,我们就能够在令牌中获得声明。对于现有用户,如果未捕获这些属性,则可以使用配置文件编辑策略来填充这些属性的值。
为了获得这些声明,您需要导航到您的用户流并选择以下内容:
用户属性:显示名称、电子邮件地址、职务名称、PhoneNumber(自定义)、邮政编码。
应用程序声明:显示名称、电子邮件地址、职务名称、PhoneNumber(自定义)、邮政编码、身份提供者访问令牌、用户是新的、用户的对象ID。
注:
只有当您使用社会IDP注册/登录时才会返回
。
https://stackoverflow.com/questions/62611802
复制相似问题