Created
September 24, 2024 00:24
-
-
Save rbrayb/a7ddff4dc375ba5ab926ce1d4e789eac to your computer and use it in GitHub Desktop.
Connecting Azure AD B2C to Kinde via OIDC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<TrustFrameworkPolicy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06" PolicySchemaVersion="0.3.0.0" TenantId="tenant.onmicrosoft.com" PolicyId="B2C_1A_signup_signin_Kinde" PublicPolicyUri="http://tenant.onmicrosoft.com/B2C_1A_signup_signin_Kinde" DeploymentMode="Development" UserJourneyRecorderEndpoint="urn:journeyrecorder:applicationinsights"> | |
<BasePolicy> | |
<TenantId>tenant.onmicrosoft.com</TenantId> | |
<PolicyId>B2C_1A_TrustFrameworkExtensions_DC</PolicyId> | |
</BasePolicy> | |
<ClaimsProviders> | |
<ClaimsProvider> | |
<Domain>kinde.com</Domain> | |
<DisplayName>Login with Kinde</DisplayName> | |
<TechnicalProfiles> | |
<TechnicalProfile Id="Kinde-OpenIdConnect"> | |
<DisplayName>Kinde</DisplayName> | |
<Description>Login with your Kinde account</Description> | |
<Protocol Name="OpenIdConnect"/> | |
<Metadata> | |
<Item Key="METADATA">https://subdomain.kinde.com/.well-known/openid-configuration</Item> | |
<Item Key="client_id">23f...ba6</Item> | |
<Item Key="response_types">code</Item> | |
<Item Key="scope">openid profile</Item> | |
<Item Key="response_mode">form_post</Item> | |
<Item Key="HttpBinding">POST</Item> | |
<Item Key="UsePolicyInRedirectUri">false</Item> | |
</Metadata> | |
<CryptographicKeys> | |
<Key Id="client_secret" StorageReferenceId="B2C_1A_KindeSecret"/> | |
</CryptographicKeys> | |
<OutputClaims> | |
<OutputClaim ClaimTypeReferenceId="issuerUserId" PartnerClaimType="sub"/> | |
<OutputClaim ClaimTypeReferenceId="tenantId" PartnerClaimType="azp"/> | |
<OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="given_name" /> | |
<OutputClaim ClaimTypeReferenceId="surName" PartnerClaimType="family_name" /> | |
<OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" /> | |
<OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="email" /> | |
<OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" AlwaysUseDefaultValue="true" /> | |
<OutputClaim ClaimTypeReferenceId="identityProvider" PartnerClaimType="iss" /> | |
<!-- <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub"/> --> | |
</OutputClaims> | |
<OutputClaimsTransformations> | |
<OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName"/> | |
<OutputClaimsTransformation ReferenceId="CreateUserPrincipalName"/> | |
<OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId"/> | |
<OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId"/> | |
</OutputClaimsTransformations> | |
<UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin"/> | |
</TechnicalProfile> | |
</TechnicalProfiles> | |
</ClaimsProvider> | |
</ClaimsProviders> | |
<UserJourneys> | |
<UserJourney Id="SignUpOrSignIn-Kinde"> | |
<OrchestrationSteps> | |
<OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin"> | |
<ClaimsProviderSelections> | |
<ClaimsProviderSelection TargetClaimsExchangeId="KindeExchange" /> | |
<ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" /> | |
</ClaimsProviderSelections> | |
<ClaimsExchanges> | |
<ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" /> | |
</ClaimsExchanges> | |
</OrchestrationStep> | |
<!-- Check if the user has selected to sign in using one of the social providers --> | |
<OrchestrationStep Order="2" Type="ClaimsExchange"> | |
<Preconditions> | |
<Precondition Type="ClaimsExist" ExecuteActionsIf="true"> | |
<Value>objectId</Value> | |
<Action>SkipThisOrchestrationStep</Action> | |
</Precondition> | |
</Preconditions> | |
<ClaimsExchanges> | |
<ClaimsExchange Id="KindeExchange" TechnicalProfileReferenceId="Kinde-OpenIdConnect" /> | |
<ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" /> | |
</ClaimsExchanges> | |
</OrchestrationStep> | |
<!-- For social IDP authentication, attempt to find the user account in the directory. --> | |
<OrchestrationStep Order="3" Type="ClaimsExchange"> | |
<Preconditions> | |
<Precondition Type="ClaimEquals" ExecuteActionsIf="true"> | |
<Value>authenticationSource</Value> | |
<Value>localAccountAuthentication</Value> | |
<Action>SkipThisOrchestrationStep</Action> | |
</Precondition> | |
</Preconditions> | |
<ClaimsExchanges> | |
<ClaimsExchange Id="AADUserReadUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserReadUsingAlternativeSecurityId-NoError" /> | |
</ClaimsExchanges> | |
</OrchestrationStep> | |
<!-- Show self-asserted page only if the directory does not have the user account already (i.e. we do not have an objectId). | |
This can only happen when authentication happened using a social IDP. If local account was created or authentication done | |
using ESTS in step 2, then an user account must exist in the directory by this time. --> | |
<OrchestrationStep Order="4" Type="ClaimsExchange"> | |
<Preconditions> | |
<Precondition Type="ClaimsExist" ExecuteActionsIf="true"> | |
<Value>objectId</Value> | |
<Action>SkipThisOrchestrationStep</Action> | |
</Precondition> | |
</Preconditions> | |
<ClaimsExchanges> | |
<ClaimsExchange Id="SelfAsserted-Social" TechnicalProfileReferenceId="SelfAsserted-Social" /> | |
</ClaimsExchanges> | |
</OrchestrationStep> | |
<!-- This step reads any user attributes that we may not have received when authenticating using ESTS so they can be sent | |
in the token. --> | |
<OrchestrationStep Order="5" Type="ClaimsExchange"> | |
<Preconditions> | |
<Precondition Type="ClaimEquals" ExecuteActionsIf="true"> | |
<Value>authenticationSource</Value> | |
<Value>socialIdpAuthentication</Value> | |
<Action>SkipThisOrchestrationStep</Action> | |
</Precondition> | |
</Preconditions> | |
<ClaimsExchanges> | |
<ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" /> | |
</ClaimsExchanges> | |
</OrchestrationStep> | |
<!-- The previous step (SelfAsserted-Social) could have been skipped if there were no attributes to collect | |
from the user. So, in that case, create the user in the directory if one does not already exist | |
(verified using objectId which would be set from the last step if account was created in the directory. --> | |
<OrchestrationStep Order="6" Type="ClaimsExchange"> | |
<Preconditions> | |
<Precondition Type="ClaimsExist" ExecuteActionsIf="true"> | |
<Value>objectId</Value> | |
<Action>SkipThisOrchestrationStep</Action> | |
</Precondition> | |
</Preconditions> | |
<ClaimsExchanges> | |
<ClaimsExchange Id="AADUserWrite" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" /> | |
</ClaimsExchanges> | |
</OrchestrationStep> | |
<OrchestrationStep Order="7" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" /> | |
</OrchestrationSteps> | |
<ClientDefinition ReferenceId="DefaultWeb" /> | |
</UserJourney> | |
</UserJourneys> | |
<RelyingParty> | |
<DefaultUserJourney ReferenceId="SignUpOrSignIn-Kinde" /> | |
<Endpoints> | |
<!--points to refresh token journey when app makes refresh token request--> | |
<Endpoint Id="Token" UserJourneyReferenceId="RedeemRefreshToken" /> | |
</Endpoints> | |
<UserJourneyBehaviors> | |
<JourneyInsights TelemetryEngine="ApplicationInsights" InstrumentationKey="410...5d0" DeveloperMode="true" ClientEnabled="false" ServerEnabled="true" TelemetryVersion="1.0.0" /> | |
<ContentDefinitionParameters> | |
<!-- <Parameter Name="campaignId">{OAUTH-KV:campaignId}</Parameter> | |
<Parameter Name="lang">{Culture:LanguageName}</Parameter> --> | |
<Parameter Name="appId">{OIDC:ClientId}</Parameter> | |
</ContentDefinitionParameters> | |
<ScriptExecution>Allow</ScriptExecution> | |
</UserJourneyBehaviors> | |
<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" /> | |
<OutputClaim ClaimTypeReferenceId="tenantId" AlwaysUseDefaultValue="true" DefaultValue="{Policy:TenantObjectId}" /> | |
</OutputClaims> | |
<SubjectNamingInfo ClaimType="sub" /> | |
</TechnicalProfile> | |
</RelyingParty> | |
</TrustFrameworkPolicy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://medium.com/the-new-control-plane/connecting-azure-ad-b2c-to-kinde-via-oidc-9bb5845e0d70