首页 > 解决方案 > 带有确认屏幕的 Azure AD B2C 重置密码自定义策略

问题描述

我在 Azure AD B2C 中设置了登录自定义策略,以便在登录流程期间自定义 GUI 动态内容并根据某些场景自定义品牌。此登录策略显示“忘记密码?” 由我的应用程序处理的链接以启动另一个自定义密码重置策略的流程。

在 B2C 提供的标准密码重置策略中,用户重置密码后,会出现一个额外的屏幕,指示密码已成功更改,并提供重新执行登录策略的链接。使用自定义策略,在重置密码后会立即调用重定向 url。

是否可以使用显示确认消息的屏幕配置密码重置策略流程的附加步骤?

标签: azure-active-directoryazure-ad-b2cidentity-experience-framework

解决方案


我也为此苦苦挣扎了好几天。通过将以下内容添加到扩展文件中,我设法使其工作。

  1. 步骤 3添加到PasswordReset UserJourney的现有 OrchestrationSteps
<UserJourney Id="PasswordReset">
  <OrchestrationSteps>
    <OrchestrationStep Order="1" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="PasswordResetUsingEmailAddressExchange" TechnicalProfileReferenceId="LocalAccountDiscoveryUsingEmailAddress" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="NewCredentials" TechnicalProfileReferenceId="LocalAccountWritePasswordUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="3" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="ShowSuccess" TechnicalProfileReferenceId="LocalAccountWritePasswordChanged" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="4" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
  </OrchestrationSteps>
  <ClientDefinition ReferenceId="DefaultWeb" />
</UserJourney>

  1. 在 BuildingBlocks/ClaimsSchema 中添加此 ClaimType
  <ClaimType Id="justResetPassword">
    <DisplayName>justResetPassword</DisplayName>
    <DataType>boolean</DataType>
    <UserHelpText>Indicates whether the user just reset their password via the forgot password feature.</UserHelpText>
    <UserInputType>Button</UserInputType>
  </ClaimType>

  1. 添加上面提到的新 TechnicalProfile:LocalAccountWritePasswordChanged
    <TechnicalProfile Id="LocalAccountWritePasswordChanged">
      <DisplayName>Changed password</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <Metadata>
        <Item Key="ContentDefinitionReferenceId">api.passwordchangesuccess</Item>
        <Item Key="language.button_continue">Back to Login</Item>
        <Item Key="language.initial_intro">Ready to login again...</Item>
        <Item Key="language.verifying_blurb">Preparing login screen.</Item>
        <!-- TODO: Hide cancel button -->
      </Metadata>
      <CryptographicKeys>
        <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
      </CryptographicKeys>
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="objectId" />
      </InputClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="justResetPassword" DefaultValue="true" />
      </OutputClaims>
    </TechnicalProfile>

  1. 修改您的依赖方文件,使其也具有新类型的outputClaim justResetPassword
<OutputClaim ClaimTypeReferenceId="justResetPassword" />

我认为诀窍在于这个新的技术配置文件有一个justResetPassword 的输出声明,所以它会触发并尝试捕获该值。因为它的数据类型是按钮,但它不显示。这一点我不是很清楚,但由于它正在工作并且我花了这么长时间才到达这里,我不会过多质疑它。

您可能会注意到这个新的技术配置文件引用了api.passwordchangesuccess. 这是我自己创建的自定义内容定义,旨在为“密码重置消息”提供更好的自定义标题。如果您不需要过多自定义成功页面,则可以使用 ContentDefinition api.selfasserted 。

重置密码后的最终结果: 截图


推荐阅读