使用 api.signuporsignin 和自定义策略自定义注册页面

Customize signup page using api.signuporsignin and custom policies

我在旅途中使用 api.signuporsignin 并自定义了登录页面,但是当我点击注册 link 时,它会转到 MS 默认注册页面而不是自定义注册。我看到这个 link 转到

https://tenant.b2clogin.com/tenant.onmicrosoft.com/B2C_1A_signup_signin/api/CombinedSigninAndSignup/unified?local=signup...

是否可以使用 api.signuporsignin 自定义注册页面?

这是我的旅程

<UserJourney Id="SignUpWithEmailOrSignInWithUsernameOrEmail">
            <OrchestrationSteps>
                <OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
                    <ClaimsProviderSelections>
                        <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninUsernameExchange" />
                    </ClaimsProviderSelections>
                    <ClaimsExchanges>
                        <ClaimsExchange Id="LocalAccountSigninUsernameExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Username" />
                    </ClaimsExchanges>
                </OrchestrationStep>
                <OrchestrationStep Order="2" Type="ClaimsExchange">
                <Preconditions>
                    <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
                    <Value>objectId</Value>
                    <Action>SkipThisOrchestrationStep</Action>
                    </Precondition>
                </Preconditions>
                <ClaimsExchanges>
                    <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" />
                </ClaimsExchanges>
            </OrchestrationStep>

...

<TechnicalProfile Id="SelfAsserted-LocalAccountSignin-Username">
                <DisplayName>Local Account Signin with Username</DisplayName>
                <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                <Metadata>
                    <Item Key="SignUpTarget">SignUpWithLogonUsernameExchange</Item>
                    <Item Key="setting.operatingMode">Username</Item>
                    <Item Key="ContentDefinitionReferenceId">api.selfasserted.test</Item>
                </Metadata>

谢谢

编辑 1:添加内容定义。我可以自定义登录页面但不能自定义注册。当您点击 立即注册 link 时,会出现默认的 MS 页面

<ContentDefinitions>
        <ContentDefinition Id="api.signuporsignin">
            <LoadUri>https://something.blob.core.windows.net/mycontainer/custom-ui.html</LoadUri>
            <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
            <DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.0.0</DataUri>
            <Metadata>
                <Item Key="DisplayName">Signin and Signup</Item>
            </Metadata>
        </ContentDefinition>
        <ContentDefinition Id="api.selfasserted.test">
            <LoadUri>https://something.blob.core.windows.net/mycontainer/custom-signup.html</LoadUri>
            <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
        <DataUri>urn:com:microsoft:aad:b2c:elements:selfasserted:1.1.0</DataUri>
            <Metadata>
            <Item Key="DisplayName">Collect information from user page</Item>
            </Metadata>
      </ContentDefinition>
    </ContentDefinitions>

正如@Allen Wu 建议的那样,在 中搜索 'api.signuporsignin' TrustFrameworkExtensions.xml,检查Loaduri是否和你设置的url一致在你的 Azure AD protal->storge account ->container.

  <ContentDefinition Id="api.signuporsignin">
    <LoadUri>https://storage1.blob.core.windows.net/root/custom-ui.html</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.0.0</DataUri>
    <Metadata>
      <Item Key="DisplayName">Signin and Signup</Item>
    </Metadata>
    <LocalizedResourcesReferences MergeBehavior="Prepend">
      <LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.signuporsignin.en" />
      <LocalizedResourcesReference Language="es" LocalizedResourcesReferenceId="api.signuporsignin.es" />
    </LocalizedResourcesReferences>
  </ContentDefinition>

查看您的信任框架基本定义和(未发布的)用户旅程的其余部分。

注册或登录页面仅提供指向“注册”页面的链接——该页面基本上跳过了编排步骤。注册或登录页面后的第二个编排步骤通常会测试用户对象 ID 声明是否存在(例如,用户是否实际登录),然后 运行 带有如果用户尝试注册而不是登录,则单独定义内容...

例如MS提供的基础策略中:

<UserJourney Id="SignUpOrSignIn">
      <OrchestrationSteps>
      
        <!-- Present the sign up or sign in page, with `api.signuporsignin` -->
        <OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
          <ClaimsProviderSelections>
            <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" />
          </ClaimsProviderSelections>
          <ClaimsExchanges>
            <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
          </ClaimsExchanges>
        </OrchestrationStep>

        <!-- 
            If the previous step did not generate a user object ID (IE - 
            sign the user in), show the sign up page.
 
            The `LocalAccountSignUpWithLogonEmail` technical profile 
            should use a diffrent content definion because it's a self-assert
            profile - in this case `api.localaccountsignup` - You'll need to
            customize this content definition too.
         -->
        <OrchestrationStep Order="2" Type="ClaimsExchange">
          <Preconditions>
            <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
              <Value>objectId</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" />
          </ClaimsExchanges>
        </OrchestrationStep>
...