在Azure AD B2C中阅读扩展声明

3
我有两个声明要存储在目录中,供我的应用程序使用。这些声明不可供用户编辑,但可供应用程序从令牌中读取。
内置策略能够检索这些声明,然而,我尝试使用自定义策略检索这些声明却没有成功。
阅读“在自定义配置文件编辑策略中创建和使用自定义属性”的下一步,需要将这些声明添加到RP和TechnicalProfile中以从目录中读取。因此,我更新了RP和读取目录的TP。
<TechnicalProfile Id="AAD-UserReadUsingAlternativeSecurityId">
<TechnicalProfile Id="AAD-UserReadUsingObjectId">
<TechnicalProfile Id="SelfAsserted-LocalAccountSignin-Email">
<TechnicalProfile Id="AAD-UserReadUsingEmailAddress">

无法确定检索2个扩展声明所缺少的内容。
2个回答

12

假设您正在通过Azure AD Graph API阅读用户旅程中的自定义声明并编写它们,那么您必须:

1:将自定义声明作为<ClaimType />添加到基本策略中。

<ClaimType Id="extension_UserAttribute1">
  <DisplayName>User Attribute 1</DisplayName>
  <DataType>string</DataType>
</ClaimType>
<ClaimType Id="extension_UserAttribute2">
  <DisplayName>User Attribute 2</DisplayName>
  <DataType>string</DataType>
</ClaimType>

2:将扩展应用程序的应用程序和对象标识符添加到“AAD-Common”技术配置文件中,该配置文件需要从Azure AD B2C目录中读取自定义声明。

<TechnicalProfile Id="AAD-Common">
  <DisplayName>Azure Active Directory</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.AzureActiveDirectoryProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    <Item Key="ApplicationObjectId">Insert the object identifier for the b2c-extensions-app application here</Item>
    <Item Key="ClientId">Insert the application identifier for the b2c-extensions-app application here</Item>
  </Metadata>
  <CryptographicKeys>
    <Key Id="issuer_secret" StorageReferenceId="TokenSigningKeyContainer" />
  </CryptographicKeys>
  ...
</TechnicalProfile>
注意:如果您想在内置策略和自定义策略中读取自定义声明,则必须使用内置应用程序的应用程序标识符和对象标识符 b2c-extensions-app,而不是自定义扩展应用程序,如Azure Active Directory B2C:在自定义配置文件编辑策略中创建和使用自定义属性教程中所建议的那样。

3:将自定义声明作为<OutputClaim />添加到以下技术配置文件中:

"AAD-UserReadUsingObjectId" 用于本地帐户登录和配置文件编辑

"AAD-UserReadUsingAlternativeSecurityId" 用于社交账户登录和配置文件编辑

"LocalAccountDiscoveryUsingEmailAddress" 和 "AAD-UserReadUsingEmailAddress" 用于本地帐户密码重置

<OutputClaims>
  ...
  <OutputClaim ClaimTypeReferenceId="extension_UserAttribute1" />
  <OutputClaim ClaimTypeReferenceId="extension_UserAttribute2" />
</OutputClaims>

4:在任何依赖方策略中,将定制声明作为 <OutputClaim /> 发布。


2
感谢 @ChrisPadget。对于仍然困惑的人,请确保从AD读取数据的用户流程步骤实际上在您的用户流程中可用。在我的情况下,我不得不添加以下内容: "最初的回答"
<OrchestrationStep Order="2" Type="ClaimsExchange">
    <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
    </ClaimsExchanges>
</OrchestrationStep>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接