【问题标题】:How to create an email only page in Azure AD B2C?如何在 Azure AD B2C 中创建仅电子邮件页面?
【发布时间】:2020-10-01 20:55:37
【问题描述】:

我想在我的登录页面前面有一个页面,其中只有一个电子邮件地址字段和一个按钮。用户单击按钮后,他们会转到另一个页面,在那里他们可以输入用户名和密码并登录。这在 B2C 中是否可行?

仅电子邮件页面:

登录页面:

步骤 1. 在 TrustFrameworkBase.xml 文件中,为 signInName 声明类型添加输入限制,以便在第一页上只能输入电子邮件地址。

<!-- Claims needed for local accounts. -->
      <!--<ClaimType Id="signInName">
        <DisplayName>Sign in name</DisplayName>
          <DisplayName>Email address</DisplayName>
        <DataType>string</DataType>
        <UserHelpText />
        <UserInputType>TextBox</UserInputType>
      </ClaimType>-->

        <ClaimType Id="signInName">
            <DisplayName>Email address</DisplayName>
            <DataType>string</DataType>
            <UserHelpText/>
            <UserInputType>TextBox</UserInputType>
            <Restriction>
                <Pattern RegularExpression="^[a-zA-Z0-9.!#$%&amp;'^_`{}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" HelpText="Please enter a valid email address." />
            </Restriction>
        </ClaimType>

第 2 步。在 TrustFrameworkBase.xml 文件中,将另一个技术配置文件添加到本地帐户声明提供程序,它会提示您输入电子邮件地址。

 <ClaimsProvider>
      <DisplayName>Local Account</DisplayName>
      <TechnicalProfiles>
          <TechnicalProfile Id="SelfAsserted-LocalAccountSignin-EmailOnly">
              <DisplayName>Local Account Signin</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.selfasserted</Item>
              </Metadata>
              <IncludeInSso>false</IncludeInSso>
              <OutputClaims>
                  <OutputClaim ClaimTypeReferenceId="signInName" Required="true" />
              </OutputClaims>
              <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
          </TechnicalProfile>
        <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
...

第 3 步。在 TrustFrameworkBase.xml 文件中,将 SelfAsserted-LocalAccountSignin-EmailOnly 添加到 SignUpOrSignIn 用户旅程中,作为编排的第一步。

<UserJourneys>
    <UserJourney Id="SignUpOrSignIn">
      <OrchestrationSteps>
          <OrchestrationStep Order="1" Type="ClaimsExchange">
              <ClaimsExchanges>
                  <ClaimsExchange Id="LocalAccountSigninEmailOnlyExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-EmailOnly" />
              </ClaimsExchanges>
          </OrchestrationStep>
        <OrchestrationStep Order="2" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
          <ClaimsProviderSelections>
            <ClaimsProviderSelection TargetClaimsExchangeId="FacebookExchange" />
            <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" />
          </ClaimsProviderSelections>
          <ClaimsExchanges>
            <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
          </ClaimsExchanges>
        </OrchestrationStep>

我仍然被提示输入密码(CSS 隐藏了该字段):

【问题讨论】:

    标签: azure azure-active-directory azure-ad-b2c


    【解决方案1】:

    A custom policy 可以使用the LocalAccounts starter pack 为这种“分页”登录实现,如下所示。

    1. the TrustFrameworkBase.xml file中,对the signInName claim type添加输入限制,这样第一页就只能输入电子邮件地址。
    <ClaimType Id="signInName">
      <DisplayName>Email address</DisplayName>
      <DataType>string</DataType>
      <UserHelpText/>
      <UserInputType>TextBox</UserInputType>
      <Restriction>
        <Pattern RegularExpression="^[a-zA-Z0-9.!#$%&amp;'^_`{}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" HelpText="Please enter a valid email address." />
      </Restriction>
    </ClaimType>
    
    1. TrustFrameworkBase.xml 文件中,将另一个技术配置文件添加到 the Local Account claims provider,它会提示您输入电子邮件地址。
    <TechnicalProfile Id="SelfAsserted-LocalAccountSignin-EmailOnly">
      <DisplayName>Local Account Signin</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.selfasserted</Item>
      </Metadata>
      <IncludeInSso>false</IncludeInSso>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="signInName" Required="true" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
    </TechnicalProfile>
    
    1. TrustFrameworkBase.xml 文件中,将 SelfAsserted-LocalAccountSignin-EmailOnly 添加到 the SignUpOrSignIn user journey 作为第一个编排步骤。
    <UserJourney Id="SignUpOrSignIn">
      <OrchestrationSteps>
        <OrchestrationStep Order="1" Type="ClaimsExchange">
          <ClaimsExchanges>
            <ClaimsExchange Id="LocalAccountSigninEmailOnlyExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-EmailOnly" />
          </ClaimsExchanges>
        </OrchestrationStep>
        <OrchestrationStep Order="2" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
          <ClaimsProviderSelections>
            <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" />
          </ClaimsProviderSelections>
          <ClaimsExchanges>
            <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
          </ClaimsExchanges>
        </OrchestrationStep>
        ...
    

    【讨论】:

    • 我已更新我的问题以反映 Chris 的解决方案。
    • 您的解决方案有效。我的扩展文件出错了。
    猜你喜欢
    • 2019-10-23
    • 1970-01-01
    • 1970-01-01
    • 2018-04-02
    • 1970-01-01
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 2020-10-18
    相关资源
    最近更新 更多