我使用Azure AD B2C自定义策略从第三方获取声明并将其映射到Azure AD B2C令牌中返回的声明 .
如果第三方以字符串形式返回声明,则我在策略中的用户旅程正常 . 我的问题是第三方以json的形式返回索赔 . 我在B2C策略的XML Schema中找不到可以处理这种情况的任何相关者 .
有没有办法使用Azure AD B2C自定义策略执行此操作?
虽然我不知道您正在使用的第三方身份提供商,但我认为您可以通过在自定义策略中添加自定义提供程序来实现添加提供程序 .
首先,根据您的帖子,我假设您正在使用Oauth / OIDC提供商 .
Example: 使用自定义策略将LinkedIn添加为身份提供者:
在 <ClaimsProviders> 元素中,添加以下XML代码段:
<ClaimsProviders>
<ClaimsProvider> <Domain>linkedin.com</Domain> <DisplayName>LinkedIn</DisplayName> <TechnicalProfiles> <TechnicalProfile Id="LinkedIn-OAUTH"> <DisplayName>LinkedIn</DisplayName> <Protocol Name="OAuth2" /> <Metadata> <Item Key="ProviderName">linkedin</Item> <Item Key="authorization_endpoint">https://www.linkedin.com/oauth/v2/authorization</Item> <Item Key="AccessTokenEndpoint">https://www.linkedin.com/oauth/v2/accessToken</Item> <Item Key="ClaimsEndpoint">https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,headline)</Item> <Item Key="ClaimsEndpointAccessTokenName">oauth2_access_token</Item> <Item Key="ClaimsEndpointFormatName">format</Item> <Item Key="ClaimsEndpointFormat">json</Item> <Item Key="scope">r_emailaddress r_basicprofile</Item> <Item Key="HttpBinding">POST</Item> <Item Key="UsePolicyInRedirectUri">0</Item> <Item Key="client_id">Your LinkedIn application client ID</Item> </Metadata> <CryptographicKeys> <Key Id="client_secret" StorageReferenceId="B2C_1A_LinkedInSecret" /> </CryptographicKeys> <OutputClaims> <OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="id" /> <OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="firstName" /> <OutputClaim ClaimTypeReferenceId="surname" PartnerClaimType="lastName" /> <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="emailAddress" /> <!--<OutputClaim ClaimTypeReferenceId="jobTitle" PartnerClaimType="headline" />--> <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="linkedin.com" /> <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" /> </OutputClaims> <OutputClaimsTransformations> <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" /> <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" /> <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" /> <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId" /> </OutputClaimsTransformations> <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" /> </TechnicalProfile> </TechnicalProfiles> </ClaimsProvider>
此外,您可以添加 <Item Key="AccessTokenResponseFormat">json</Item> 以声明json类型的 endpoints .
<Item Key="AccessTokenResponseFormat">json</Item>
您可以使用本文档中的自定义策略,查看有关将LinkedIn添加为身份提供商的更多详细信息 .
额外:
我不知道您使用的第三个身份提供商,如果有帮助,请告诉我 .
1 回答
虽然我不知道您正在使用的第三方身份提供商,但我认为您可以通过在自定义策略中添加自定义提供程序来实现添加提供程序 .
首先,根据您的帖子,我假设您正在使用Oauth / OIDC提供商 .
Example: 使用自定义策略将LinkedIn添加为身份提供者:
在
<ClaimsProviders>
元素中,添加以下XML代码段:此外,您可以添加
<Item Key="AccessTokenResponseFormat">json</Item>
以声明json类型的 endpoints .您可以使用本文档中的自定义策略,查看有关将LinkedIn添加为身份提供商的更多详细信息 .
额外:
我不知道您使用的第三个身份提供商,如果有帮助,请告诉我 .