有什么方法可以为 Azure AD B2C 自定义策略中的输入提供默认值吗?

Jac*_* A. 2 azure-ad-b2c

I am working on integrating Azure AD B2C into an existing shopping cart application, replacing an existing user identity solution.

I have already created a custom policy to implement user registration / sign-up and integrated it into the normal account creation process. However, I am having a problem with integrating registration during the checkout process.

With the old IDP, the checkout process first collects the user's name and email address. After that has been collected, the user is given the option to create an account with that information (if they are not already logged in). In order to avoid confusing double-entry of the email address, I would like to pass the email address that the user already entered to the B2C sign-up policy and have it fill in the email address input on the form.

Is there any way to do this? I don't find anything like this being addressed in the B2C documentation.

Jas*_*SFT 6

您可以将注册策略与声明解析程序结合使用。在查询参数中发送电子邮件。它\xe2\x80\x99会将电子邮件预先填充到文本框中。

\n

https://learn.microsoft.com/en-us/azure/active-directory-b2c/claim-resolver-overview

\n


Jac*_* A. 6

根据@JasSuri 链接的文档,我能够提出一个解决方案。

要实现此目的,您需要修改注册技术配置文件。您必须添加三件事:

  1. IncludeClaimResolvingInClaimsHandling将有价值的项目添加true到元数据中
  2. DefaultValue属性添加到email输入声明,并使用适当的声明解析器符号作为值
  3. 将属性添加AlwaysUseDefaultValueemail输入声明true作为值

我使用了Oauth2 键值声明解析器(支持任意查询字符串参数)和名为 的查询参数register_email

由此产生的技术概况如下所示:

<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
  <DisplayName>Email signup</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    <Item Key="IpAddressClaimReferenceId">IpAddress</Item>
    <Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
    <Item Key="language.button_continue">Create</Item>
    <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item> <!-- ADD THIS -->
  </Metadata>
  <CryptographicKeys>
    <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
  </CryptographicKeys>
  <InputClaims>
    <!-- ADD DefaultValue AND AlwaysUseDefaultValue ATTRIBUTES BELOW -->
    <InputClaim ClaimTypeReferenceId="email"
        DefaultValue="{OAUTH-KV:register_email}"
        AlwaysUseDefaultValue="true" />
  </InputClaims>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="objectId" />
    <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />
    <OutputClaim ClaimTypeReferenceId="newPassword" Required="true" />
    <OutputClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
    <OutputClaim ClaimTypeReferenceId="executed-SelfAsserted-Input" DefaultValue="true" />
    <OutputClaim ClaimTypeReferenceId="authenticationSource" />
    <OutputClaim ClaimTypeReferenceId="newUser" />
  </OutputClaims>
  <ValidationTechnicalProfiles>
    <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />
  </ValidationTechnicalProfiles>
  <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
</TechnicalProfile>
Run Code Online (Sandbox Code Playgroud)