# Passing custom SAML data as ApplicationMetaData and not UserMetaData

**URL:** <https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554>\
**Category:** Get Help\
**Tags:** amazon-cognito, saml\
**Created:** [August 11, 2022, 8:08am UTC](https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554 "2022-08-11T08:08:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![avivk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/avivk/32/33541_2.png) [@avivk](https://community.auth0.com/u/avivk)\
**Post date:** [August 11, 2022, 8:08am UTC](https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554/1 "2022-08-11T08:08:15Z")

</div>

hey, I have static common XML attributes that I would like to pass for each user, I’m performing and IDP-initiated-flow using AWS Cognito \<\> Auth0 \<\> SP,

I have configured:

1. Rule to support static data with mappings (see below)
2. Added application metadata (see below)

but for some reason data is not passed correctly to SAML Response, if I change the mappings from client\_metadata to app\_metadata it works, but I would like to have same data For all users (and not setup each time).

am I’m missing something? how can I pass static XML data for every SAML response user?

thanks!

 ![image](https://global.discourse-cdn.com/auth0/original/3X/e/d/ed4deee343af493f1432c898e013f17b6078456f.png)

```auto
function changeSamlConfiguration(user, context, callback) {
  context.samlConfiguration = context.samlConfiguration || {};
  context.samlConfiguration.audience = 'federate-uat.ipipeline.com:saml2';
  context.samlConfiguration.mapUnknownClaimsAsIs = true;
  context.samlConfiguration.mapIdentities = false;
  console.log("aAA", context.clientMetadata);
  context.samlConfiguration.mappings = {
     "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "user_id",
     "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress": "email",
     "CompanyIdentifier": "client_metadata.CompanyIdentifier",
  "ChannelName": "client_metadata.ChannelName",
  "Action": "client_metadata.Action",
     "Groups": "client_metadata.Groups",
  "TimeoutURL": "client_metadata.TimeoutURL"
   };
  callback(null, user, context);
}

```

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [August 12, 2022, 6:14am UTC](https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554/2 "2022-08-12T06:14:21Z")

</div>

This is because the SAML mappings are always read from the `user` object only. In the first line of your mapping, you have set `"user_id"` - so when the actual mapping happens later the mapper will look for `user.user_id`. But there is no `user.client_metadata.ChannelName` so the latter part of the mapping does not work.

A trick here is to attach the attributes to the `user` object temporarily. For example:

```auto
user.client_metadata = client_metadata;

```

Now, when you specify `client_metadata.ChannelName` in the mapping, the mapper will later check for `user.client_metadata.ChannelName` which actually exists, so it’ll work.

This does not update the actual user profile. It’s just a temporary assignment that gets discarded later.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 12, 2022, 8:06am UTC](https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554/3 "2022-08-12T08:06:11Z")

</div>

Thanks for helping on this one @thameera !

---

<div class="post-metadata">

**Author:** ![avivk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/avivk/32/33541_2.png) [@avivk](https://community.auth0.com/u/avivk)\
**Post date:** [August 14, 2022, 7:19am UTC](https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554/4 "2022-08-14T07:19:30Z")

</div>

awesome, works - thanks!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 5:24pm UTC](https://community.auth0.com/t/passing-custom-saml-data-as-applicationmetadata-and-not-usermetadata/88554/5 "2022-12-21T17:24:28Z")

</div>


