我在 Azure AD B2C 中设置了登录自定义策略,以便在登录流程中自定义 GUI 动态内容,并根据特定场景自定义品牌。此登录策略显示“忘记密码?”由我的应用程序处理的链接以启动另一个自定义密码重置策略的流程。
在 B2C 提供的标准密码重置策略中,一旦用户重置了密码,就会出现一个额外的屏幕,指示密码已成功更改,并提供重新执行登录策略的链接。使用自定义策略,在重置密码后立即调用重定向 url。
是否可以使用显示确认消息的屏幕为密码重置策略流程配置额外的步骤?
最佳答案
我也为此苦苦挣扎了好几天。我已通过将以下内容添加到扩展文件来设法使其正常工作。
- 将步骤 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>
- 在 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>
- 添加上面提到的新 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>
- 修改您的依赖方文件,使其也具有新类型的 outputClaim justResetPassword
<OutputClaim ClaimTypeReferenceId="justResetPassword" />
我认为诀窍是这个新的技术配置文件有一个 justResetPassword 的输出声明,所以它会触发以 try catch 该值。因为它的数据类型是按钮,虽然它不显示。这一点我不是很清楚,但由于它正在工作并且我花了这么长时间才到达这里,所以我不会过多质疑它。
您可能会注意到这个新的技术配置文件引用了 api.passwordchangesuccess
的 ContentDefinition。这是我自己创建的自定义内容定义,用于为“密码重置消息”提供更好的自定义标题。如果您不需要对成功页面进行过多自定义,则可以改用 ContentDefinition api.selfasserted。
重置密码后的最终结果: Screenshot
关于azure-active-directory - 带有确认屏幕的 Azure AD B2C 重置密码自定义策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53406351/