Currently, I’m using Auth0 as an IdP for login via SAML. The client requires that the email address should be truncated to only 30 Char… is there a way to truncate email address or any function to get the substring of email.
You can create a rule to truncate the email address and assign it to a new field, e.g. called email_truncated, then map the email_truncated field to SAML claims.
Here is the detailed steps:
Create a new rule named truncate email address by following this document.
Use the following code as reference for the rule truncate email address:
function truncate_email_address(user, context, callback) {
function truncate_email(email) {
// implement the code of truncating email to 30 charactors
}
if (context.clientID === "YOUR_SAML_CLIENT_ID") {
user.email_truncated = truncate_email(user.email);
}
callback(null, user, context);
}
Update the mappings of SAML
{
“mappings”: {
“email_truncated”: “http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress”,
// you can also map the original email as a reference
“email”: “http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress_untruncated”
}
}
With the above changes, in the SAML response, you should have the truncated email in the http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress attribute, and the untruncated email in the http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress_untruncated attribute.