gpt4 book ai didi

azure - AD B2C - 如何在密码重置流程中设置自定义电子邮件验证

转载 作者:行者123 更新时间:2023-12-02 08:23:16 37 4
gpt4 key购买 nike

我需要自定义当用户重置密码时从 AD B2C 发送给用户的电子邮件。

我按照本文档设置了自助密码重置流程,效果很好: https://learn.microsoft.com/en-us/azure/active-directory-b2c/add-password-reset-policy?pivots=b2c-custom-policy

为了提供用于密码重置的品牌电子邮件,我正在遵循此代码,因为看起来唯一的其他选择是使用当前处于公共(public)预览版的显示控件(因此我无法在生产中使用它们) : https://github.com/azure-ad-b2c/samples/tree/master/policies/custom-email-verifcation

自述文件明确指出它也可用于密码重置,但代码仅提供登录电子邮件验证的示例。

我尝试在各种 TechnicalProfiles 中添加 verificationCode OutputClaim,但我无法可视化自定义 verificationCode 所提供的 javascript 代码所需的文本框。

我想也许我应该使用特定的 ContentDefinition,但我真的很难找到更新自定义策略 xml 的正确方法。

更新以澄清:在注册示例中,验证码添加到 LocalAccountSignUpWithLogonEmail TechnicalProfile:

<ClaimsProvider>
<DisplayName>Local Account</DisplayName>
<TechnicalProfiles>
<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>
<!-- Demo: Disable the email verification-->
<Item Key="EnforceEmailVerification">False</Item>
</Metadata>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="objectId"/>
<OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true"/>

<!--Demo: Add the verification code claim type-->
<OutputClaim ClaimTypeReferenceId="verificationCode" Required="true"/>

由于我正在处理密码重置(由以下 SubJourney 安排),我们可以看到它引用了 LocalAccountDiscoveryUsingEmailAddress TechnicalProfile第一步:

    <SubJourney Id="PasswordReset" Type="Call">
<OrchestrationSteps>
<!--Sample: Validate user's email address. Run this step only when user resets the password-->
<OrchestrationStep Order="1" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="PasswordResetUsingEmailAddressExchange" TechnicalProfileReferenceId="LocalAccountDiscoveryUsingEmailAddress" />
</ClaimsExchanges>
</OrchestrationStep>

<!--Sample: Collect and persist a new password. Run this step only when user resets the password-->
<OrchestrationStep Order="2" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="NewCredentials" TechnicalProfileReferenceId="LocalAccountWritePasswordUsingObjectId" />
</ClaimsExchanges>
</OrchestrationStep>
</OrchestrationSteps>
</SubJourney>

因此,我将 verificationCode 添加到 LocalAccountDiscoveryUsingEmailAddress TechnicalProfile:

    <!-- This technical profile forces the user to verify the email address that they provide on the UI. Only after email is verified, the user account is
read from the directory. -->
<TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">
<DisplayName>Reset password using email address</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.localaccountpasswordreset</Item>
<Item Key="UserMessageIfClaimsTransformationBooleanValueIsNotEqual">Your account has been locked. Contact your support person to unlock it, then try again.</Item>
</Metadata>
<CryptographicKeys>
<Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
</CryptographicKeys>
<IncludeInSso>false</IncludeInSso>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="verificationCode" Required="true"/>
<OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />
<OutputClaim ClaimTypeReferenceId="objectId" />
<OutputClaim ClaimTypeReferenceId="userPrincipalName" />
<OutputClaim ClaimTypeReferenceId="authenticationSource" />
</OutputClaims>
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="REST-EmailVerification"/>
<ValidationTechnicalProfile ReferenceId="AAD-UserReadUsingEmailAddress" />
</ValidationTechnicalProfiles>
</TechnicalProfile>

但是相关的TextBox没有在页面中渲染。

更新 2:我找到了文本框未呈现的原因。它与使用的ContentDefinition有关。尽管使用了 api.localaccountpasswordreset 内容定义,但通过使用 api.selfasserted.profileupdate 内容定义,会显示该字段。现在我还在努力。

更新 3:我能够使用 api.selfasserted.profileupdate 内容定义使其工作。一旦完成与验证 API 的集成,我将发布完整的解决方案。

最佳答案

verified.email 输出声明与密码重置技术配置文件中对您的 displayControl 的引用交换,即 LocalAccountDiscoveryUsingEmailAddresshttps://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-email-sendgrid#make-a-reference-to-the-displaycontrol

其本质上是完全相同的步骤,除了您对 LocalAccountDiscoveryUsingEmailAddress 技术配置文件进行“引用”更改以在该特定页面上显示显示控件,该页面在第 1 步中引用密码重置过程收集和验证用户的电子邮件。

        <TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">
<DisplayName>Reset password using email address</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.localaccountpasswordreset</Item>
<Item Key="UserMessageIfClaimsTransformationBooleanValueIsNotEqual">Your account has been locked. Contact your support person to unlock it, then try again.</Item>
</Metadata>
<CryptographicKeys>
<Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
</CryptographicKeys>
<IncludeInSso>false</IncludeInSso>
<DisplayClaims>
<DisplayClaim DisplayControlReferenceId="emailVerificationControl" />
</DisplayClaims>
<OutputClaims>
<!--<OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />-->
<OutputClaim ClaimTypeReferenceId="email" />
<OutputClaim ClaimTypeReferenceId="objectId" />
<OutputClaim ClaimTypeReferenceId="userPrincipalName" />
<OutputClaim ClaimTypeReferenceId="authenticationSource" />

如果您想要使用与“注册”不同的电子邮件模板来重置密码,请重新创建一个新的显示控件并引用不同的模板。

关于azure - AD B2C - 如何在密码重置流程中设置自定义电子邮件验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66706904/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com