Azure B2C 自定义策略条件 OrchestrationStep

Azure B2C custom policy conditional OrchestrationStep

我正在尝试根据自定义属性的值引入新的编排步骤。我的要求是仅当 myattribute(boolean attribute) 的值设置为 true 时我才想执行编排步骤。 myattribute 的值设置为 true 或 false。 我正在做这样的事情。

<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
  <Value>False</Value>
  <Value>extension_myattribute</Value>
  <Action>SkipThisOrchestrationStep</Action>
</Precondition>

但是无论 myattribute 的值如何,都不会跳过这一步。我已将 myattribute 添加为 AAD-UserReadUsingObjectId 的 OutPutClaims 的一部分。我可以在 C# 中看到 extension_myattribute 的值。

任何指向比较值的示例的指针都会对我有很大帮助。

你尝试做的应该有效,至少在入门包中有非常相似的例子。

https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/blob/f376b431dc0c7353faf52632d3d3f735ad5978a1/scenarios/source/aadb2c-ief-terms-of-use/SignUpOrSigninToUDateTime.xml

    <!-- Check if the user has selected to sign in using one of the social providers -->
    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <Preconditions>
        <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
          <Value>authenticationSource</Value>
          <Value>socialIdpAuthentication</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
      </Preconditions>
      <ClaimsExchanges>
        <ClaimsExchange Id="FacebookExchange" TechnicalProfileReferenceId="Facebook-OAUTH" />
        <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="SelfAsserted-Input-ToU-LocalAccountSignUp" />
      </ClaimsExchanges>
    </OrchestrationStep>

xsd 还明确提到 "true" 和 "false"

<xs:attribute use="required" name="ExecuteActionsIf" type="xs:boolean" >
  <xs:annotation>
    <xs:documentation>
      Specifies if the actions in this precondition should be performed if the test is true or false.
    </xs:documentation>
  </xs:annotation>
</xs:attribute>

也许您的索赔尚未确定?还是您将属性和声明混合在一起?

对于 ClaimEquals 前提条件,第一个 <Value /> 必须设置为声明类型,第二个 <Value /> 必须设置为声明值:

<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
  <Value>extension_myattribute</Value>
  <Value>False</Value>
  <Action>SkipThisOrchestrationStep</Action>
</Precondition>

对于 布尔值 声明,可能的值为 "True" 和 "False"。