Cómo almacenar reclamos de IdentityServer 3 en Azure AD B2C o simplemente incluirlo en tokens emitidos por AAD B2C
Me pregunto si es posible propagar un reclamo de oid o básicamente cualquier otro reclamo emitido por Identity Server 3 al AAD B2C y hacer que sea parte del token emitido por Azure AD B2C. Necesitamos tener una identificación original en el lado del cliente y todo lo que podemos obtener de los reclamos sub y oid es una identificación de una cuenta de usuario AAD B2C. También me gustaría hacer lo mismo con los reclamos de roles. Cualquier ayuda sería muy apreciada.
[EDITADO]
Así es como se ve el perfil técnico de mi configuración de Identity Server en la Política personalizada (TrustFrameworkExtensions.xml):
<TechnicalProfile Id="IdentityServerProfile">
<DisplayName>IdentityServer</DisplayName>
<Description>Login with your IdentityServer account</Description>
<Protocol Name="OpenIdConnect"/>
<OutputTokenFormat>JWT</OutputTokenFormat>
<Metadata>
<Item Key="METADATA">https://{identity_server_hostname}/identity/.well-known/openid-configuration</Item>
<Item Key="ProviderName">https://{identity_server_hostname}/identity</Item>
<Item Key="client_id">00000000-0000-0000-0000-000000000000</Item>
<Item Key="IdTokenAudience">00000000-0000-0000-0000-000000000000</Item>
<Item Key="response_types">code</Item>
<Item Key="scope">openid profile customScope</Item>
<Item Key="UsePolicyInRedirectUri">false</Item>
<Item Key="AccessTokenResponseFormat">json</Item>
<Item Key="HttpBinding">POST</Item>
</Metadata>
<CryptographicKeys>
<Key Id="client_secret" StorageReferenceId="B2C_1A_IdentityServerAppSecret"/>
</CryptographicKeys>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="IdentityServer" />
<OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" />
<OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="tid" />
<OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="sub" />
</OutputClaims>
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName"/>
<OutputClaimsTransformation ReferenceId="CreateUserPrincipalName"/>
<OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId"/>
</OutputClaimsTransformations>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop"/>
</TechnicalProfile>
Y aquí está el registro original de Application Instights del registro con el correlationId dado:
{
"TenantId": "{tenant} .onmicrosoft.com", "PolicyId": "B2C_1A_signup_signin_capcom", "RedirectUri": "http: // localhost: 3000 /", "Parámetros adicionales":
"client_info": "1", "x-client-SKU": "MSAL.JS", "x-client-Ver": "0.1.5", "client-request-id": "a0ef9d95-ba21- 4796-ad65-bc9e2b8c5e89 "}," Nonce ":" bf198ee6-e084-433d-885c-2icsoftf0292b3d "," State ":" 7f732141-498e-4445-9efe-9b0d54178ef6 "," ClientId03: "01245-3" -9bca-054d6201ac00 "," ResponseType ":" id_token "," ResponseMode ":" fragment "," ResponseRedirector ":
"URI": "http: // localhost: 3000 / "," D ": falso," WF ": verdadero," R ": falso," S ": falso}," AppModelVersion ": 1," ScopedProviders ":
]}
Algo que noté y que encontré extraño es el valor ResponseType. En nuestro perfil técnico se establece en código y aquí su valor es id_token.
[EDITADO 2] El reclamo de socialIdpUserId finalmente pasa. También hay una respuesta debajo de cuál era el problema. Ahora, todavía tengo un problema con tener FirstName, lastName y displayName. He seguido el mismo patrón que hice para socialIdpUserId, pero lo único que puedo ver son los valores predeterminados. Aquí están mis configuraciones para ellos:
1) Definición de tipos de reclamo:
<ClaimType Id="displayName">
<DisplayName>Display Name</DisplayName>
<DataType>string</DataType>
<DefaultPartnerClaimTypes>
<Protocol Name="OAuth2" PartnerClaimType="unique_name" />
<Protocol Name="OpenIdConnect" PartnerClaimType="displayName" />
<Protocol Name="SAML2" PartnerClaimType="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" />
</DefaultPartnerClaimTypes>
<UserHelpText>Your display name.</UserHelpText>
<UserInputType>TextBox</UserInputType>
</ClaimType>
...
<ClaimType Id="givenName">
<DisplayName>Given Name</DisplayName>
<DataType>string</DataType>
<DefaultPartnerClaimTypes>
<Protocol Name="OAuth2" PartnerClaimType="given_name" />
<Protocol Name="OpenIdConnect" PartnerClaimType="given_name" />
<Protocol Name="SAML2" PartnerClaimType="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname" />
</DefaultPartnerClaimTypes>
<UserHelpText>Your given name (also known as first name).</UserHelpText>
<UserInputType>TextBox</UserInputType>
</ClaimType>
<ClaimType Id="surname">
<DisplayName>Surname</DisplayName>
<DataType>string</DataType>
<DefaultPartnerClaimTypes>
<Protocol Name="OAuth2" PartnerClaimType="family_name" />
<Protocol Name="OpenIdConnect" PartnerClaimType="family_name" />
<Protocol Name="SAML2" PartnerClaimType="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname" />
</DefaultPartnerClaimTypes>
<UserHelpText>Your surname (also known as family name or last name).</UserHelpText>
<UserInputType>TextBox</UserInputType>
</ClaimType>
Y generar reclamos en el perfil técnico de mi IdP:
<TechnicalProfiles>
<TechnicalProfile Id="CapcomProfile">
...
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="displayName" />
<OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="firstName" DefaultValue="No" />
<OutputClaim ClaimTypeReferenceId="surname" PartnerClaimType="lastName" DefaultValue="Name" />
...
Y finalmente, la definición de salida RP:
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="displayName" />
<OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="givenName" />
<OutputClaim ClaimTypeReferenceId="surname" PartnerClaimType="surname" DefaultValue="Not found in IdP" />
...
¿Alguna sugerencia