Ошибка Azure B2C Rest API по-прежнему создается учетная запись

Я создал REST API для Azure B2C, чтобы возвращать претензию или ошибку во время процесса создания учетной записи.

В моей пользовательской политике я подключил API, и он был вызван.

Однако, если API возвращает 400 или 409, учетная запись все равно создается, но пользователю отображается сообщение об ошибке на странице создания. Учетная запись пользователя все еще создается, несмотря на ошибку.

Затем пользователь исправляет ошибку и снова нажимает кнопку «Создать», но не может создать учетную запись, поскольку она уже была создана.

Я выполнил инструкции здесь:

https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-rest-api-claims-validation

Мой поставщик заявлений выглядит так, а заявка от REST API называется VerifiedDateOfBirth:

<ClaimsProvider>
            <DisplayName>REST API</DisplayName>
            <TechnicalProfiles>
                <TechnicalProfile Id="REST-Validation">
                    <DisplayName>Check date of birth</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">{REST URL}}</Item>
                        <Item Key="SendClaimsIn">Body</Item>
                        <!-- Set AuthenticationType to Basic or ClientCertificate in production environments -->
                        <Item Key="AuthenticationType">None</Item>
                        <!-- REMOVE the following line in production environments -->
                        <Item Key="AllowInsecureAuthInProduction">true</Item>
                    </Metadata>
                    <InputClaims>
                        <!-- Claims sent to your REST API -->
                        <InputClaim ClaimTypeReferenceId="dateOfBirth" />
                    </InputClaims>
                    <OutputClaims>
                        <!-- Claims parsed from your REST API -->
                        <OutputClaim ClaimTypeReferenceId="VerifiedDateOfBirth" />                       
                    </OutputClaims>
                    <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
                </TechnicalProfile>
            </TechnicalProfiles>
        </ClaimsProvider>

И технический профиль:

    <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
                    <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>
                        <Item Key="language.button_continue">Create</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" />
                        <!-- Optional claims, to be collected from the user -->
                        <OutputClaim ClaimTypeReferenceId="displayName" />
                        <OutputClaim ClaimTypeReferenceId="givenName" />
                        <OutputClaim ClaimTypeReferenceId="surName" />
                        <OutputClaim ClaimTypeReferenceId="dateOfBirth" Required="true" />
                        <OutputClaim ClaimTypeReferenceId="VerifiedDateOfBirth" Required="true" />
                    </OutputClaims>
                    <ValidationTechnicalProfiles>
                        <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />
                        <ValidationTechnicalProfile ReferenceId="REST-Validation" />
                    </ValidationTechnicalProfiles>
                    <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
                </TechnicalProfile>

Когда возникает ошибка, я вижу следующую ошибку на странице создания:

введите описание изображения здесь

Мне нужно добавить дополнительную конфигурацию?


person Michael Edwards    schedule 16.03.2021    source источник


Ответы (1)


Порядок ваших профилей проверки имеет значение в вашем LocalAccountSignUpWithLogonEmail техническом профиле. Похоже, что первой проверкой была запись учетной записи пользователя.

Попробуйте вместо этого:

<ValidationTechnicalProfiles>
  <ValidationTechnicalProfile ReferenceId="REST-Validation" />
  <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />
</ValidationTechnicalProfiles>
person Brad C.    schedule 16.03.2021