This article describes how to add authentication for an Intuit account to an Azure AD B2C custom policy.
Architecture
The following diagram illustrates the authentication flow for an Intuit account to an Azure AD B2C custom policy.
For information about Intuit and OAuth 2.0, see https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization.
Prerequisites
- If you don’t already have one, then you must create an Azure AD B2C tenant that is linked to your Azure subscription.
- Prepare your Azure AD B2C tenant by creating the token signing and encryption keys and creating the Identity Experience Framework applications.
- Download one of the starter packs for Azure AD B2C from Microsoft’s GitHub repository.
Configure an Intuit application
- Log in to https://developer.intuit.com/app/developer/myapps.
- On the My Apps Dashboard page, select Create an app.
- On the Create app page, select QuickBooks Online and Payments.
- On the QuickBooks Online and Payments page, enter the following fields and then select Create app:
- App name
- Scope: com.intuit.quickbooks.accounting
- On the app page, in the Development Settings > Keys & credentials > Keys section, copy the Client ID and Secret fields.
- On the app page, in the Development Settings > Keys & credentials > Redirect URIs section, enter the following fields and then select Save:
- Redirect URL: Enter either
https://your-tenant-name.b2clogin.com/your-tenant-name.onmicrosoft.com/oauth2/authresp
if you use the built-in domain orhttps://your-domain-name/your-tenant-name.onmicrosoft.com/oauth2/authresp
if you use a custom domain for the Redirect URL field. Replaceyour-tenant-name
with your tenant name andyour-domain-name
with your custom domain.
- Redirect URL: Enter either
Add the client secret for the Intuit application as a policy key
- Sign in to the Azure AD B2C portal.
- Select Identity Experience Framework.
- Select Policy keys.
- Select Add.
- In the Create a key section, enter the following fields and then select Create:
- Options:
Manual
- Name:
IntuitClientSecret
- Secret: Paste the Client secret field that was copied in the previous section.
- Options:
Configure claims transformation
We must also configure a CreateDisplayName claims transformation that formats the givenName and surname claim types that are retrieved for the authenticated user.
- Open the TrustFrameworkExtensions.xml file.
- Find the BuildingBlocks element and then the ClaimsTransformations element. If they don’t exist, then add them to the TrustFrameworkPolicy element.
- Add the following ClaimsTransformation element to the ClaimsTransformations element.
<ClaimsTransformation Id="CreateDisplayName" TransformationMethod="FormatStringMultipleClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="givenName" TransformationClaimType="inputClaim1" />
<InputClaim ClaimTypeReferenceId="surname" TransformationClaimType="inputClaim2" />
</InputClaims>
<InputParameters>
<InputParameter Id="stringFormat" DataType="string" Value="{0} {1}" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="displayName" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
- Find the ClaimsProviders element. If it doesn’t exist, then add it to the TrustFrameworkPolicy element.
- Add the following ClaimsProvider element to the ClaimsProviders element.
<ClaimsProvider>
<DisplayName>Claims Transformation</DisplayName>
<TechnicalProfiles>
<TechnicalProfile Id="ClaimsTransformation-CreateDisplayName">
<DisplayName>Create Display Name Claims Transformation</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.ClaimsTransformationProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="displayName" />
</OutputClaims>
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="CreateDisplayName" />
</OutputClaimsTransformations>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
</TechnicalProfile>
</TechnicalProfiles>
</ClaimsProvider>
Configure Intuit as an identity provider
- Open the TrustFrameworkExtensions.xml file.
- Find the ClaimsProviders element. If it doesn’t exist, then add it to the TrustFrameworkPolicy element.
- Add the following ClaimsProvider element to the ClaimsProviders element. Replace
your-intuit-client-id
with the Client ID field that was copied in the Configure an Intuit application section.
<ClaimsProvider>
<Domain>intuit.com</Domain>
<DisplayName>Intuit</DisplayName>
<TechnicalProfiles>
<TechnicalProfile Id="Intuit-OAuth2">
<DisplayName>Intuit</DisplayName>
<Protocol Name="OAuth2" />
<Metadata>
<Item Key="client_id">your-intuit-client-id</Item>
<Item Key="authorization_endpoint">https://appcenter.intuit.com/connect/oauth2</Item>
<Item Key="AccessTokenEndpoint">https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer</Item>
<Item Key="ClaimsEndpoint">https://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfo</Item>
<Item Key="scope">openid profile email</Item>
<Item Key="HttpBinding">POST</Item>
<Item Key="token_endpoint_auth_method">client_secret_basic</Item>
<Item Key="BearerTokenTransmissionMethod">AuthorizationHeader</Item>
<Item Key="UsePolicyInRedirectUri">false</Item>
</Metadata>
<CryptographicKeys>
<Key Id="client_secret" StorageReferenceId="B2C_1A_IntuitClientSecret" />
</CryptographicKeys>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" AlwaysUseDefaultValue="true" />
<OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="intuit.com" AlwaysUseDefaultValue="true" />
<OutputClaim ClaimTypeReferenceId="issuerUserId" PartnerClaimType="sub" />
<OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="givenName" />
<OutputClaim ClaimTypeReferenceId="surname" PartnerClaimType="familyName" />
<OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="email" />
</OutputClaims>
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" />
<OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" />
<OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" />
</OutputClaimsTransformations>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" />
</TechnicalProfile>
</TechnicalProfiles>
</ClaimsProvider>
Add a user journey
- Open the TrustFrameworkBase.xml file.
- Copy the UserJourney element that includes
Id="SignUpOrSignIn"
. - Open the TrustFrameworkExtensions.xml file and find the UserJourneys element. If it doesn’t exist, then add it to the TrustFrameworkPolicy element.
- Paste the UserJourney element that was copied in step 2 to the UserJourneys element and replace the Id attribute for this UserJourney element from
"SignUpOrSignIn"
to"IntuitSignUpOrSignIn"
.
Add the identity provider to the user journey
- Add the claims provider that was configured in the Configure Intuit as an identity provider section to the user journey that was added in the previous section.
<OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
<ClaimsProviderSelections>
...
<ClaimsProviderSelection TargetClaimsExchangeId="IntuitExchange" />
</ClaimsProviderSelections>
...
</OrchestrationStep>
<OrchestrationStep Order="2" Type="ClaimsExchange">
...
<ClaimsExchanges>
<ClaimsExchange Id="IntuitExchange" TechnicalProfileReferenceId="Intuit-OAuth2" />
</ClaimsExchanges>
...
</OrchestrationStep>
Add the claims transformation to the user journey
- Add the claims provider that was configured in the Configure claims transformation section to the user journey that was added in the Add a user journey section. This must be between after the AADUserReadUsingAlternativeSecurityId claims exchange and the SelfAsserted-Social claims exchange.
<OrchestrationStep Order="4" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimsExist" ExecuteActionsIf="false">
<Value>givenName</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="false">
<Value>surname</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="ClaimsTransformation-CreateDisplayName" TechnicalProfileReferenceId="ClaimsTransformation-CreateDisplayName" />
</ClaimsExchanges>
</OrchestrationStep>
Configure the relying party policy
- Open the SignUpOrSignIn.xml file.
- Replace the ReferenceId attribute for the DefaultUserJourney element from
"SignUpOrSignIn"
to"
.
SignUpOrSignIn"Intuit
<RelyingParty>
<DefaultUserJourney ReferenceId="IntuitSignUpSignIn" />
...
</RelyingParty>
Upload and test the custom policy
- Upload all policy files in the following order to your Azure AD B2C tenant:
- TrustFrameworkBase.xml
- TrustFrameworkLocalization.xml
- TrustFrameworkExtensions.xml
- SignUpOrSignIn.xml
- Test the B2C_1A_signup_signin policy from your Azure AD B2C tenant.