Auth0 Home Blog Docs

Adding custom SAML attribute when auth0 is SP




Currently I’m using Auth0 as a service provider for login via SAML. The client requires a custom saml attribute value like this.


This information is stored in Groups field of Users in Auth0. How do I modify rules or any other configuration so that the SAML response sent from Auth0 contains the specified attribute value. Please help with this.

Thanks in advance.


Have you checked the rules info in docs?



I am not 100% certain I follow. You mention that Auth0 is the service provider, but you also mention you want Auth0 to generate the saml response. Did you really mean Auth0 was the IdP and needed to send a SAML response to some 3rd party service provider?

If so we have a rule template that you could modify to help this mapping:

function (user, context, callback) {
  context.samlConfiguration.mappings = {
     "": "user_id",
     "":   "email",
     "":           "name",
     "":           "user_metadata.favorite_food",
     "":        "app_metadata.shipping_address"

  callback(null, user, context);

With this template the claim on the left hand side will be the the saml attribute name and the string on the right is the property on the user profile that will be mapped as the value.


Hi @sgmeyer,

Sorry for the confusion, Auth0 is indeed the IdP. This is what is currently in Rules.

context.samlConfiguration.mappings = {
     "": "email",
     "": "email",
     "": "name",
 //    "":  "given_name",
 //    "": "family_name",
 //    "": "upn",
     "": "groups",
     "memberOf": "groups"

But when I see the SAML response getting submitted (in browser) to authenticate the client by decrypting, the XML doesn’t have the memberOf field. It only has the following fields in the attribute statement.

         <saml:Attribute Name="">
         <saml:Attribute Name="">
         <saml:Attribute Name="">
         <saml:Attribute Name="">

Please help me find out what should be configured to add the additional attribute here.


@balamanohar.b I think the problem is you need to update you saml-addon configuration with this:

"mapUnknownClaimsAsIs": true,

This tells Auth0 to map any unknown claims/attributes as specified without prepending a URI to it.

Here is what I did to mock this out:

  1. I created a google social connection for my users. When I logged in as my user I set app_metadata:

  2. I configured my SAML Add-on with:

  "mappings": {
    "user_id": "",
    "email": "",
    "groups": "memberof"
  "passthroughClaimsWithNoMapping": false,
  "mapUnknownClaimsAsIs": true,
  "mapIdentities": false
  1. Then I debugged the request and received this:

A quick note on step #2. Initially I showed how to do this with a rule, that is still totally legit, because the mappings in rules are a bit more flexible than in the add-on. I also tested this with the rule you have above and got the results in step 3 after adding "mapUnknownClaimsAsIs": true, to the saml add-on’s configuration.


Thanks a lot @sgmeyer . It worked for our use case.