Skip to content

Instantly share code, notes, and snippets.

@woloski
Last active February 9, 2023 10:37
Show Gist options
  • Save woloski/8162612 to your computer and use it in GitHub Desktop.
Save woloski/8162612 to your computer and use it in GitHub Desktop.
Salesforce Auth0 rule. This is the default mapping Auth0 will use for Salesforce. You can create a new Rule and change this with whatever you want.
function (user, context, callback) {
//
// this rule can be used if you have chosen to use Username as the way to identify a user in Salesforce. Notice that we are mapping the email to the nameidentifier.
//
if (context.clientName === 'Salesforce') {
context.samlConfiguration.mappings = {
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier': 'email',
'User.Username': 'email',
'User.Email': 'email',
'User.FirstName': 'given_name',
'User.ProfileId': 'salesforce_profile_id',
'User.LastName': 'family_name'
}
}
callback(null, user, context)
}
function (user, context, callback) {
if (context.clientName === 'Salesforce') {
context.samlConfiguration.mappings = {
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier': 'user_id',
'User.Username': 'email',
'User.Email': 'email',
'User.FirstName': 'given_name',
'User.ProfileId': 'salesforce_profile_id',
'User.LastName': 'family_name'
}
}
callback(null, user, context)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment