Pass in Hard coded values in SAML mapping

Overview

We are using Auth0 acting as SAML Identity Provider and using an existing application to perform SAML SSO and everything is working fine.
We have a new requirement where we want to add hard coded values in the SAML response that will not be in the user's profile. Is this possible? Is there some kind of guideline/document for this?

Cause

***Informational***

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. But the trick here is to 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 used as a trick to update 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: https://auth0.com/docs/authenticate/protocols/saml/saml-configuration/customize-saml-assertions#example-changing-the-saml-token-lifetime-and-use-upn-as-nameid

Recommended content

No recommended content found...