Created
January 26, 2021 10:27
-
-
Save saltukalakus/92928444f91411bec1eb75d7312e70a0 to your computer and use it in GitHub Desktop.
Multiple attributes to a single attribute in SAML response when Auth0 is the SAML IdP
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
function (user, context, callback) { | |
// Execute the rule only for the required Apps's client ID | |
var samlIdpClientId = 'LYkMiVolEzhDzaTQJPg6mRI468blVFU4'; | |
if (context.clientID !== samlIdpClientId) { | |
return callback(null, user, context); | |
} | |
user.tmpMemberOf = ""; | |
function appendMember(memberOf) { | |
user.tmpMemberOf += memberOf + ":"; | |
} | |
if (user.app_metadata && user.app_metadata.memberOf) { | |
user.app_metadata.memberOf.forEach(appendMember); | |
} | |
context.samlConfiguration.mappings = { | |
"userMemberOf": "tmpMemberOf" | |
}; | |
callback(null, user, context); | |
} |
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
{ | |
"email": "johndough@gmail.com", | |
"email_verified": false, | |
"updated_at": "2021-01-26T10:23:02.889Z", | |
"user_id": "auth0|5bb836bb44a3697cd1f26db8", | |
"nickname": "johndough", | |
"identities": [ | |
{ | |
"user_id": "5bb836bb44a3697cd1f26db8", | |
"provider": "auth0", | |
"connection": "Username-Password-Authentication", | |
"isSocial": false | |
} | |
], | |
"created_at": "2018-10-06T04:14:51.920Z", | |
"name": "johndough@gmail.com", | |
"user_metadata": {}, | |
"last_password_reset": "2019-10-11T13:39:00.517Z", | |
"app_metadata": { | |
"memberOf": [ | |
"env_A", | |
"env_B" | |
] | |
}, | |
"last_ip": "31.142.76.23", | |
"last_login": "2021-01-26T10:23:02.889Z", | |
"logins_count": 122, | |
"blocked_for": [], | |
"guardian_authenticators": [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment