Additional special characters required in username - * & %

We are doing lazy migration where the existing DB has a lot of account with some special characters that aren’t allowed in Auth0 like * & %

What options do we have?

Cheers,
Karthick.

Hi @karuissobusy

Thank you for reaching out to us!

I understand you are asking which options are available for a lazy migration from an existing database when many accounts have usernames containing characters that Auth0 does not accept in usernames, such as *, &, and %.

Recommended Solution

Keep the legacy usernames in a separate field and use email or a sanitized username as the Auth0 identifier, so the migration does not depend on the special characters being valid in Auth0.

As the characters you mention are not in the set of accepted username characters, usernames containing them cannot be stored as-is and we can recommend one of the following options, depending on which best fits your implementation.

Option A: Keep usernames and transform them during migration (recommended if login by legacy username must continue)

  1. Map each legacy username to an allowed value in your custom database login and get-user scripts. For example, replace * with a permitted character such as _ and keep the original value in the user profile’s user_metadata or app_metadata.
  2. Return the transformed value in the username property of the profile object passed to the callback, because the connection has Requires Username enabled.
  3. Check that login works with both the transformed username and the user’s email, since Auth0 authenticates with either when Requires Username is enabled.

Option B: Use email as the primary identifier (recommended if legacy usernames are not a strict requirement)

  1. Disable Requires Username in the Database Connection settings if your users can sign in with email.
  2. Import users with their email address as the unique identifier. Store the legacy username in user_metadata so it remains searchable for support and reconciliation.

Option C: Use a Pre User Registration Action for new sign-ups

  • Create a Pre User Registration Action to reject or normalize usernames that contain disallowed characters on new sign-ups.

Allow me to share some additional Knowledge Articles which should prove useful:

Hope this information helped you achieve the desired flow and complete the migration!

Have a great one,
Gerald