Azure B2C 自定义策略 - 自定义技术配置文件在注册中不起作用

问题描述 投票:0回答:1

我正在尝试在 SignUpOrSignIn 用户旅程中使用本地帐户的自定义技术配置文件。 我在我的 customtrustframeworkextensions.xml (base:trustframeworkextensions.xml) 中创建了以下技术配置文件:

<ClaimsProvider>
          <DisplayName>Local Account</DisplayName>
          <TechnicalProfiles>
            <TechnicalProfile Id="CustomLocalAccountSignUpWithLogonEmail">
              <DisplayName>Email signup</DisplayName>
              <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
              <Metadata>
                <Item Key="IpAddressClaimReferenceId">IpAddress</Item>
                <Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
              </Metadata>
              <CryptographicKeys>
                <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
              </CryptographicKeys>
              <InputClaims>
                <InputClaim ClaimTypeReferenceId="email" />
              </InputClaims>
              <OutputClaims>
                <OutputClaim ClaimTypeReferenceId="objectId" />
                <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />
                <OutputClaim ClaimTypeReferenceId="newPassword" Required="true" />
                <OutputClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
                <OutputClaim ClaimTypeReferenceId="executed-SelfAsserted-Input" DefaultValue="true" />
                <OutputClaim ClaimTypeReferenceId="authenticationSource" />
                <OutputClaim ClaimTypeReferenceId="newUser" />
                <OutputClaim ClaimTypeReferenceId="extension_XXX" />
                <!-- Optional claims, to be collected from the user -->
                <OutputClaim ClaimTypeReferenceId="displayName" />
                <OutputClaim ClaimTypeReferenceId="givenName" />
                <OutputClaim ClaimTypeReferenceId="surName" />
              </OutputClaims>
              <ValidationTechnicalProfiles>
                <ValidationTechnicalProfile ReferenceId="REST-ValidateProfile" />
              </ValidationTechnicalProfiles>
              <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
            </TechnicalProfile>
          </TechnicalProfiles>
        </ClaimsProvider>
        <ClaimsProvider>

REST-ValidateProfile 如下所示:

        <ClaimsProvider>
        <DisplayName>REST APIs</DisplayName>
        <TechnicalProfiles>
            <TechnicalProfile Id="REST-ValidateProfile">
                <DisplayName>Check yyy and zzz Rest API</DisplayName>
                <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                <Metadata>
                    <!-- Set the ServiceUrl with your own REST API endpoint -->
                    <Item Key="ServiceUrl">https://asd</Item>
                    <Item Key="SendClaimsIn">Body</Item>
                    <!-- Set AuthenticationType to Basic or ClientCertificate in production environments -->
                    <Item Key="AuthenticationType">ApiKeyHeader</Item>
                    <!-- REMOVE the following line in production environments -->
                    <Item Key="AllowInsecureAuthInProduction">false</Item>
                </Metadata>
                <CryptographicKeys>
                    <Key Id="Api-key" StorageReferenceId="B2C_1A_key" />
                </CryptographicKeys>
                <InputClaims>
                    <!-- Claims sent to your REST API -->
                    <InputClaim ClaimTypeReferenceId="email" />
                    <InputClaim ClaimTypeReferenceId="extension_xxx" PartnerClaimType="xxx" />                                                                                                        
                </InputClaims>
                <OutputClaims>
                    <!-- Claims parsed from your REST API -->
                    <OutputClaim ClaimTypeReferenceId="extension_yyy" PartnerClaimType="yyy" />
                    <OutputClaim ClaimTypeReferenceId="extension_zzz" PartnerClaimType="zzz" />
                </OutputClaims>
                <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
            </TechnicalProfile>
    </ClaimsProvider>

我已修改 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="CustomLocalAccountSignUpWithLogonEmail" />
      </ClaimsExchanges>
    </OrchestrationStep>

当我运行自定义策略并选择注册时,浏览器显示错误:“由于发生内部服务器错误,无法显示页面。”

Application Insights 中有一些更具体的细节:

异常消息:在租户策略“B2C_1A_DEV_signup_signin”中 ID 为“CustomLocalAccountSignUpWithLogonEmail”的技术配置文件中指定的输出声明类型“objectId”未指定 UserInputType 或 DefaultValue,也不会从 ValidationTechnicalProfile 中检索。异常类型:InvalidDefinitionException

当我使用名称“LocalAccountSignUpWithLogonEmail”编辑技术配置文件时,一切正常,并且 ClaimsExChange 如下所示:

<ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="CustomLocalAccountSignUpWithLogonEmail" />

但是当我更改修改后的技术配置文件的名称时,策略不再起作用。在我看来,索赔交换不起作用什么的。我不明白为什么,因为我找不到任何其他引用 LocalAccountSignUpWithLogonEmail 的地方。

我想使用自定义技术配置文件,因为想要删除一些输出声明而不触及基本策略。

azure-ad-b2c azure-ad-b2c-custom-policy
1个回答
0
投票

技术配置文件“CustomLocalAccountSignUpWithLogonEmail”具有 objectID 的输出声明,这在您编写内容时很常见。最常见的模式是:

技术简介

-> 验证技术 1 配置文件

-> 验证技术 2 简介

验证技术配置文件 1 可能会调用您的 REST 来验证配置文件,然后调用验证技术配置文件 2 对目录执行写入操作。当您写入目录时,它会输出一个 objectID,该 ID 会将其输出到您的技术配置文件中,并且该错误将消失。

© www.soinside.com 2019 - 2024. All rights reserved.