You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Entra External Identities:自定义注册时的验证码邮件模板

自定义Entra External Identities账户验证码邮件HTML模板的方法
  • 确认支持范围:Entra External Identities(原Azure AD B2C)的验证码邮件自定义,目前仅能通过**自定义策略(Custom Policies)**实现,默认用户流(User Flows)暂不支持直接修改HTML模板。

  • 通过自定义策略配置步骤:

    1. 先搭建好自定义策略的基础框架(比如基于SocialAndLocalAccounts模板创建)。
    2. 在自定义策略的XML文件中,找到<ClaimsProviders>节点,添加包含邮件发送逻辑的声明提供器,启用自定义邮件模板:
      <ClaimsProvider>
        <DisplayName>Email Verification</DisplayName>
        <TechnicalProfiles>
          <TechnicalProfile Id="EmailVerify">
            <DisplayName>Email Verification</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.localaccountsignup.emailverify</Item>
              <Item Key="EmailVerificationContentType">text/html</Item>
            </Metadata>
            <CryptographicKeys>
              <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
            </CryptographicKeys>
            <InputClaims>
              <InputClaim ClaimTypeReferenceId="email" />
            </InputClaims>
            <OutputClaims>
              <OutputClaim ClaimTypeReferenceId="email" />
              <OutputClaim ClaimTypeReferenceId="verificationCode" />
            </OutputClaims>
          </TechnicalProfile>
        </TechnicalProfiles>
      </ClaimsProvider>
      
    3. 定义邮件HTML模板内容:在<ContentDefinitions>节点下添加对应内容定义,可将HTML文件托管在Blob存储(通过LoadUri引用)或直接内嵌:
      <ContentDefinition Id="api.localaccountsignup.emailverify">
        <LoadUri>https://your-storage-container.blob.core.windows.net/templates/verify-email.html</LoadUri>
        <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
        <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.13</DataUri>
        <Metadata>
          <Item Key="DisplayName">Email Verification Page</Item>
        </Metadata>
      </ContentDefinition>
      
    4. 在HTML模板中用{verificationCode}占位符插入验证码,示例结构:
      <html>
        <body style="font-family: Arial, sans-serif;">
          <h3>请验证你的账户</h3>
          <p>你的验证码为:<strong>{verificationCode}</strong></p>
          <p>该验证码10分钟内有效</p>
        </body>
      </html>
      
    5. 将修改后的XML策略文件上传到Entra External Identities的策略管理界面。
  • 关键注意事项:

    • 托管HTML的存储账户需配置CORS规则,允许Entra External Identities域名访问。
    • 自定义策略需正确配置密钥容器和依赖组件,确保邮件发送流程正常。
    • Woodgrove示例的邮件模板也是基于自定义策略实现的,可参考其样式结构调整自己的模板。

内容的提问来源于stack exchange,提问作者Kaheff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 12:24:51