# Where to normalize email in SSO SAML Enterprise Connections?

**URL:** <https://community.auth0.com/t/where-to-normalize-email-in-sso-saml-enterprise-connections/150212>\
**Category:** Get Help\
**Tags:** connections, saml-enterprise-connection\
**Created:** [October 21, 2024, 9:51pm UTC](https://community.auth0.com/t/where-to-normalize-email-in-sso-saml-enterprise-connections/150212 "2024-10-21T21:51:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmAB](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vmab/32/61549_2.png) [@vmAB](https://community.auth0.com/u/vmAB)\
**Post date:** [October 21, 2024, 9:51pm UTC](https://community.auth0.com/t/where-to-normalize-email-in-sso-saml-enterprise-connections/150212/1 "2024-10-21T21:51:12Z")

</div>

- We have SAML Enterprise connections into the application.
- This SAML IDP uses CamelCase identifiers before the @
- Auth0 normalizes all emails coming close to the username-password database to lowercase, as does our app when creating permissions
- Auth0 maps the CamelCase@domain to email, and doesn’t normalize to lowercase
- We would like to normalize where Auth0 won’t and use [a management action to update that user](https://community.auth0.com/t/updating-user-profile-from-actions/85206), but [updating the email address on users from SAML connections is 400 forbidden](https://community.auth0.com/t/unable-to-update-users-email/115906)
- CamelCase@domain doesn’t match camelcase@domain, permissions fail, and they are signed out

At this point it looks like we need to add a whole additional layer of normalization to the entire app to handle this edge case… OR move to a secondary and worse field in the JWT like `usermetadata.email_normalized` everywhere we check (a reliable source of bugs)

Is there no way to just keep the `email` field normalized with SAML users?  
If the enterprise connection upserts the Auth0 user at login, they won’t normalize, and the email is unchangable, is this just a bug Auth0 expects every SSO integration to run into eventually?

---

<div class="post-metadata">

**Author:** ![vmAB](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vmab/32/61549_2.png) [@vmAB](https://community.auth0.com/u/vmAB)\
**Post date:** [November 4, 2024, 3:30pm UTC](https://community.auth0.com/t/where-to-normalize-email-in-sso-saml-enterprise-connections/150212/2 "2024-11-04T15:30:09Z")

</div>

The solution was to, in a post-login action, use js to normalize the token as it’s being created.

```auto
exports.onExecutePostLogin = async (event, api) => {

  const extras = {
    email: event.user.email?.toLowerCase()
   // other custom attributes
  }

  // Set the custom claims.
  for (const [key, value] of Object.entries(extras)) {
    api.idToken.setCustomClaim(key, value);
    api.accessToken.setCustomClaim(key, value);
  }  
};

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 18, 2024, 3:30pm UTC](https://community.auth0.com/t/where-to-normalize-email-in-sso-saml-enterprise-connections/150212/3 "2024-11-18T15:30:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
