在Azure AD B2C中注册后如何使用户返回登录页面?

时间:2020-07-28 19:50:46

标签: azure azure-active-directory azure-ad-b2c claims-based-identity

当用户在系统中注册时,该用户将作为登录用户自动重定向到我们的应用程序。我希望在注册后将他重定向到签名页面。我想要这种行为,因为在访问系统之前,用户需要获得管理员的批准。我使用自定义策略。

我试图使用“ SM-Noop”会话管理器,但是它不起作用。有我的代码:

<!--Local account sign-up page-->
    <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />
        <OutputClaim ClaimTypeReferenceId="newPassword" Required="true" />
        <OutputClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
        <OutputClaim ClaimTypeReferenceId="mobile" />
        <OutputClaim ClaimTypeReferenceId="extension_phoneExtension" />
        <OutputClaim ClaimTypeReferenceId="givenName" />
        <OutputClaim ClaimTypeReferenceId="surName" />
        <OutputClaim ClaimTypeReferenceId="extension_company" />
        <OutputClaim ClaimTypeReferenceId="streetAddress" />
        <OutputClaim ClaimTypeReferenceId="city" />
        <OutputClaim ClaimTypeReferenceId="state" />
        <OutputClaim ClaimTypeReferenceId="country" />
        <OutputClaim ClaimTypeReferenceId="postalcode" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>

编辑1: 解决方案似乎是添加orchestrationSteps。有一个链接可以执行此操作,但是需要重置密码:www.stackoverflow.com/a/62878136 就我而言,它无法正常工作,因为我无法在同一userJourney中添加两个CombinedSignInAndSignUp,因此它崩溃了。还有其他想法吗?

Edit2: 我对SignUpSignIn有政策:

 <UserJourney Id="SignUpOrSignIn">
  <OrchestrationSteps>

    <OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
      <ClaimsProviderSelections>
        <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" />
      </ClaimsProviderSelections>
      <ClaimsExchanges>
        <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
      </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>

    <!-- This step reads any user attributes that we may not have received when in the token. -->
    <OrchestrationStep Order="3" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <OrchestrationStep Order="4" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />

  </OrchestrationSteps>
  <ClientDefinition ReferenceId="DefaultWeb" />
</UserJourney>

仍然试图弄清楚在我的TrustFrameworkExtensions.xml中放入Order =“ 5”等等的内容

1 个答案:

答案 0 :(得分:0)

以下是您可以执行的配置:

索赔类型(从B2C端打印消息)

<ClaimType Id="userMessage">
        <DisplayName></DisplayName>
        <DataType>string</DataType>
        <UserInputType>Paragraph</UserInputType>
    </ClaimType>

ClaimsTransformation

<ClaimsTransformation Id="GetUserMessage" TransformationMethod="CreateStringClaim">
        <InputParameters>
            <InputParameter Id="value" DataType="string" Value="[![Your Account has been successfully created. To continue click on the sign-in link below.][1]][1]" />
        </InputParameters>
        <OutputClaims>
            <OutputClaim ClaimTypeReferenceId="userMessage" TransformationClaimType="createdClaim" />
        </OutputClaims>
    </ClaimsTransformation>

技术资料:

<TechnicalProfile Id="SelfAsserted-UserMessage">
      <DisplayName>After Registration</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>
        <!--Demo: hide the continue and cancel buttons -->
        <Item Key="setting.showContinueButton">false</Item>
        <Item Key="setting.showCancelButton">false</Item>
      </Metadata>
      <InputClaimsTransformations>
        <InputClaimsTransformation ReferenceId="GetUserMessage" />
      </InputClaimsTransformations>
      <InputClaims>
         <InputClaim ClaimTypeReferenceId="userMessage" />
      </InputClaims>
      <OutputClaims>
        <!--Demo: Show the paragraph claim with the message to the user -->
        <OutputClaim ClaimTypeReferenceId="userMessage" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>

用户历程:

<OrchestrationStep Order="3" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="4" Type="ClaimsExchange">
    <Preconditions>
        <Precondition Type="ClaimsExist" ExecuteActionsIf="false">
          <Value>extension_isApproved</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
         <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
          <Value>extension_isApproved</Value>
          <Value>True</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
      </Preconditions>
      <ClaimsExchanges>
        <ClaimsExchange Id="SendClaims" TechnicalProfileReferenceId="SelfAsserted-UserMessage" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="5" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
    </OrchestrationSteps>

注意:确保在“ AAD-UserReadUsingObjectId ”中添加以下声明:

<OutputClaim ClaimTypeReferenceId="extension_isApproved" />

还可以在“ SelfAsserted-UserMessage ”配置文件中的内容定义中,具有自定义页面,该页面具有登录页面的链接。下面是默认显示方式的屏幕截图。

enter image description here