Configure Auth0 for Salesforce Multi-Factor Authentication Compliance
Last Updated:
Overview
Auth0 requires specific configurations to comply with Salesforce Multi-Factor Authentication (MFA) requirements. Administrators configure OpenID Connect (OIDC) or Security Assertion Markup Language (SAML) settings to ensure the authentication response includes the necessary MFA indicators. For OIDC, Auth0 returns an amr claim containing mfa in the JSON Web Token (JWT), while SAML requires an Auth0 Action to set the correct AuthnContextClassRef value.
Applies To
- Auth0
- Salesforce
- OpenID Connect (OIDC)
- Security Assertion Markup Language (SAML)
Solution
How does Auth0 handle OpenID Connect for Salesforce MFA?
The amr value in the returned JSON Web Token (JWT) from Auth0 contains mfa, which Salesforce recognizes as a valid MFA indicator. Review the following JWT example that contains the MFA indicator after Auth0 completes the MFA process via OIDC.
...
"amr": [
"mfa"
],
...
Configure Security Assertion Markup Language For Salesforce MFA
The SAML AuthnContext is dynamic but does not match the specific values required by Salesforce by default. Create an Auth0 Action to provide the correct AuthnContextClassRef by performing the following steps.
- Create a new Post-Login Action in the Auth0 Dashboard.
- Enter the following code to set the appropriate SAML context.
exports.onExecutePostLogin = async (event, api) => { const samlpClientName = [AUTH0-APPLICATION-NAME]; // replace with Application name from tenant with 'SAML Web Application' configured. https://auth0.com/docs/authenticate/protocols/saml/saml-sso-integrations/enable-saml2-web-app-addon const mfaCheck = event?.authentication?.methods.find(item => item.name === 'mfa'); const samlpClientTransactionName = event?.client?.name; const samlpClientCheck = samlpClientName === samlpClientTransactionName; const samlpIdpCall = ( event?.transaction?.protocol === 'samlp' ); // Test if 1. MFA is completed 2. The specific SAML Application is used and 3. The transaction is SAML with this tenant acting as an IdP if (mfaCheck && samlpClientCheck && samlpIdpCall) { api.samlResponse.setAuthnContextClassRef('urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract'); } };
- Deploy the Action and add it to the Post-Login flow.
Auth0 returns a SAMLResponse to the Service Provider (SP) with the following relevant SAML element upon completion of the login process.
...
<saml:AuthnContext>
<saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract
</saml:AuthnContextClassRef>
</saml:AuthnContext>
...
NOTE: The event.authentication.method return type description is available in the Actions Triggers: post-login - Event Object documentation. Information on SAML manipulation using Actions is available in the api.samlResponse.setAuthnContextClassRef(authnContextClassRef) documentation.