Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arcseldon/dffdd5646724217abcba3829c471fde3 to your computer and use it in GitHub Desktop.
Save arcseldon/dffdd5646724217abcba3829c471fde3 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