Pass in Hard-coded values in SAML mapping

Problem statement

We use Auth0 acting as SAML Identity Provider and use an existing application to perform SAML SSO. We want to add hard-coded values in the SAML response that will not be in the user’s profile. Is there a guideline/document for this?

Solution

You can use a rule to add hard-coded values to a SAML response. Even in the rules, the mapping takes only user attributes. You can temporarily set a value in the user object so it appears as if it’s a user property. Here is an example:

user.fixed_value = 'Testing123';
context.samlConfiguration.mappings = {
  'fixed_attribute': 'user.fixed_value'
};

It’s important to note that the ‘fixed_value’ is not persisted in the user profile. It’s only a transient value for updating the SAML configuration. The attribute will stay only for the duration of the rules execution.

There are a couple of examples that use this method in this document: Customize SAML Assertions