В Azure AD B2C: как связать социальную учетную запись пользователя с уже существующей локальной учетной записью при первом входе из социальной сети?

Как я понимаю из документации, Azure AD B2C создает новую локальную учетную запись для каждого пользователя, который поступает из социальной сети, такой как GMail / Facebook, при первом входе в систему (поправьте меня, если я ошибаюсь). Однако я хочу перехватить это и связать пользователя с уже существующей (собственной) локальной учетной записью без создания новой локальной учетной записи с помощью настраиваемых политик.


comment
Вы создали собственные политики? Планируете ли вы сопоставить локальный вход в систему с входом в социальную сеть с адресом электронной почты для вошедшего в систему пользователя?   -  person Chris Padgett    schedule 21.03.2018
comment
Привет, Крис, большое спасибо. Да, я пытаюсь создать настраиваемую политику для этого (впервые пользователь настраиваемой политики). В этом случае локальный логин не имеет адреса электронной почты. Итак, как только пользователь вошел в систему с помощью входа в социальную сеть, я хочу дать конечному пользователю возможность связать свою локальную учетную запись, попросив его заполнить локальные учетные данные для входа (имя пользователя и пароль), а затем проверить учетные данные перед связыванием . Как мне добиться этого в индивидуальной политике?   -  person venkatr    schedule 21.03.2018


Ответы (2)


Образец Wingtip содержит пример этот поток.

См. файл проверяющей стороны "B2C_1A_link" и путь пользователя" Ссылка " для справки.

Обратите внимание, что этот путь пользователя побуждает конечного пользователя войти в систему с локальной учетной записью, прежде чем он войдет в систему с учетной записью социальной сети.

person Chris Padgett    schedule 21.03.2018
comment
Спасибо за быстрый ответ, Крис, я попробую и вернусь, если потребуется. Пометить это как ответ. - person venkatr; 21.03.2018

Подробный пример приведен здесь.

Обновление «идентификаторов пользователей» свяжет учетную запись социальной сети с локальной учетной записью.

Этого можно достичь, пройдя путь пользователя, аналогичный приведенному ниже.

<UserJourney Id="AccountLinkage">
  <PreserveOriginalAssertion>false</PreserveOriginalAssertion>
  <OrchestrationSteps>
    <!-- Demo: The following orchestration step is always executed. 
         Asks user to sign-in with local account (only)-->
    <OrchestrationStep Order="1" Type="ClaimsProviderSelection" ContentDefinitionReferenceId="api.idpselections">
      <ClaimsProviderSelections>
        <ClaimsProviderSelection TargetClaimsExchangeId="LocalAccountSigninEmailExchange" />
      </ClaimsProviderSelections>
    </OrchestrationStep>

    <!-- Demo: Sign-in with local account-->
    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <!-- Demo: After user is sign-in, it reads the user, by user object ID,
         from the Azure AD identity store. An error is raised if the user does not exist. -->
    <OrchestrationStep Order="3" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <!-- Demo: After user is sign-in, and we have the user object ID.
        Now, ask the user to re-sign-in, but this time with
        one of the social account. This orchestration step, displays the sign-in with social
        account buttons.
        Note, You may want to add additional social accounts here-->
    <OrchestrationStep Order="4" Type="ClaimsProviderSelection" ContentDefinitionReferenceId="api.idpselections">
      <ClaimsProviderSelections>
        **<ClaimsProviderSelection TargetClaimsExchangeId="GoogleExchange" />
        <ClaimsProviderSelection TargetClaimsExchangeId="AmazonAccountExchange" />**
      </ClaimsProviderSelections>
    </OrchestrationStep>

    <!-- Demo: Run the sign-in with social account, based on user choice (from previous step)
        Note, You may want to add additional social accounts here -->
    <OrchestrationStep Order="5" Type="ClaimsExchange">
      <ClaimsExchanges>
        **<ClaimsExchange Id="GoogleExchange" TechnicalProfileReferenceId="Google-OAUTH" />
        <ClaimsExchange Id="AmazonAccountExchange" TechnicalProfileReferenceId="AmazonAccount-OAuth2" />**
      </ClaimsExchanges>
    </OrchestrationStep>

    <!-- Demo: Updates the social account for a user, identified by the object
         identifier for the user, in the Azure AD identity store. 
         An error is raised if the user does not exist. -->
    <OrchestrationStep Order="6" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AAD-UserWriteUsingAlternativeSecurityId-ThrowIfNotExists" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId-ThrowIfNotExists" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <!-- Demo: Re-reads the user, by user object Id, from the Azure Active Directory.
         An error is raised if the user does not exist. -->
    <OrchestrationStep Order="7" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectIdAfter" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <!-- Demo: Issues a JWT token to the relying party. -->
    <OrchestrationStep Order="8" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
  </OrchestrationSteps>
</UserJourney>

Затем создайте политику LinkExternalAccount.xml, аналогичную приведенной ниже.

<RelyingParty>
<!-- Demo: This relying party policy executes the `AccountLinkage` user journey.
Please see the B2C_1A_Link_TrustFrameworkExtensions policy for more details -->
<DefaultUserJourney ReferenceId="AccountLinkage" />
<TechnicalProfile Id="PolicyProfile">
  <DisplayName>PolicyProfile</DisplayName>
  <Protocol Name="OpenIdConnect" />
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="displayName" />
    <OutputClaim ClaimTypeReferenceId="givenName" />
    <OutputClaim ClaimTypeReferenceId="surname" />
    <OutputClaim ClaimTypeReferenceId="email" />
    <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub"/>
    <OutputClaim ClaimTypeReferenceId="identityProvider" />
  </OutputClaims>
  <SubjectNamingInfo ClaimType="sub" />
</TechnicalProfile>

Как только мы запустим наш «Linkexternalaccount.xml», он будет перенаправлен на нашу локальную учетную запись для входа в систему, а после успешного входа в систему он запросит выбор IDP и на основе выбора пользователя атрибут «Идентификационные данные пользователя» будет обновлен. Мы можем проверить то же самое, запросив пользователя. Образец удостоверения пользователя выглядит следующим образом:

 **"userIdentities": [
    {
        "issuer": "google.com",
        "issuerUserId": "MTA5MjA5ODQwNzAyNjc3NTEzMzM5"
    }**
person Venkatesh    schedule 09.11.2018