根据使用Azure B2C自定义策略中的ClaimsResolver的其他输入声明来设置输入声明的值

时间:2020-07-23 10:06:59

标签: azure azure-ad-b2c

我有以下两个输入声明

<InputClaim ClaimTypeReferenceId="isAccessFlow" DefaultValue="{OAUTH-KV:access_flow}" AlwaysUseDefaultValue="true"/>
<InputClaim ClaimTypeReferenceId="prompt"  DefaultValue="select_account"/>

仅当 isAccessFlow 值不为真时,我才想将“提示” 输入声明的值分配为'select_account'。 在这种情况下,我无法弄清楚如何编写输入声明转换以达到要求。

1 个答案:

答案 0 :(得分:0)

索赔类型

 <ClaimType Id="isAccessFlow">
    <DisplayName>Access Flow</DisplayName>
    <DataType>string</DataType>
  </ClaimType>
  <ClaimType Id="prompt">
    <DisplayName>prompt</DisplayName>
    <DataType>string</DataType>
  </ClaimType>

技术资料

<TechnicalProfile Id="ParseAccessFlow">
    <DisplayName>Access Flow</DisplayName>
    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.ClaimsTransformationProtocolProvider,Web.TPEngine, Version=1.0.0.0,
     Culture=neutral, PublicKeyToken=null" />
    <Metadata>
    <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item>
    </Metadata>
    <InputClaims>
    <InputClaim ClaimTypeReferenceId="isAccessFlow" DefaultValue="{OAUTH-KV:data_flow}" AlwaysUseDefaultValue="true"/>
    </InputClaims>
    <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="isAccessFlow" />
    </OutputClaims>
    <OutputClaimsTransformations>
    <OutputClaimsTransformation ReferenceId="AssignedAccessFlowValue" />
    <OutputClaimsTransformation ReferenceId="ChangeToLower" />
    </OutputClaimsTransformations>
    <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>
    <TechnicalProfile Id="PromptFlow">
      <DisplayName>Prompt</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.ClaimsTransformationProtocolProvider,Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <InputClaimsTransformations>
      <InputClaimsTransformation ReferenceId="AssignedDefaultValue" />          
      </InputClaimsTransformations>
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="prompt"  />
      </InputClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="prompt"/>
      </OutputClaims>
    </TechnicalProfile>

ClaimsTransformations

<ClaimsTransformation Id="AssignedAccessFlowValue" TransformationMethod="FormatStringClaim">
    <InputClaims>
      <InputClaim ClaimTypeReferenceId="isAccessFlow" TransformationClaimType="inputClaim" />
    </InputClaims>
    <InputParameters>
      <InputParameter Id="stringFormat" DataType="string" Value="{0}" />
    </InputParameters>
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="isAccessFlow" TransformationClaimType="outputClaim" />
    </OutputClaims>
  </ClaimsTransformation>
  <ClaimsTransformation Id="ChangeToLower" TransformationMethod="ChangeCase">
    <InputClaims>
      <InputClaim ClaimTypeReferenceId="isAccessFlow" TransformationClaimType="inputClaim1" />
    </InputClaims>
    <InputParameters>
      <InputParameter Id="toCase" DataType="string" Value="LOWER" />
    </InputParameters>
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="isAccessFlow" TransformationClaimType="outputClaim" />
    </OutputClaims>
  </ClaimsTransformation>      
  <ClaimsTransformation Id="AssignedDefaultValue" TransformationMethod="CreateStringClaim">
    <InputParameters>
      <InputParameter Id="value" DataType="string" Value="select_account" />
    </InputParameters>
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="prompt" TransformationClaimType="createdClaim" />
    </OutputClaims>
  </ClaimsTransformation>

用户旅程

<UserJourney Id="PromptCheck">
  <OrchestrationSteps>
    <OrchestrationStep Order="1" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AccessFlow" TechnicalProfileReferenceId="ParseAccessFlow" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="2" Type="ClaimsExchange">
    <Preconditions>
        <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
          <Value>isAccessFlow</Value>
          <Value>true</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
      </Preconditions>
      <ClaimsExchanges>
        <ClaimsExchange Id="Assigned" TechnicalProfileReferenceId="PromptFlow" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="3" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
  </OrchestrationSteps>
  <ClientDefinition ReferenceId="DefaultWeb" />
</UserJourney>