# What is the list of allowed characters for usernames in Keycloak?

**URL:** <https://forum.keycloak.org/t/what-is-the-list-of-allowed-characters-for-usernames-in-keycloak/29468>\
**Category:** Miscellanaeous\
**Created:** [January 23, 2025, 4:18pm UTC](https://forum.keycloak.org/t/what-is-the-list-of-allowed-characters-for-usernames-in-keycloak/29468 "2025-01-23T16:18:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catheline](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/catheline/32/11915_2.png) [@Catheline](https://forum.keycloak.org/u/Catheline)\
**Post date:** [January 23, 2025, 4:18pm UTC](https://forum.keycloak.org/t/what-is-the-list-of-allowed-characters-for-usernames-in-keycloak/29468/1 "2025-01-23T16:18:04Z")

</div>

Hello everyone,

I’m trying to determine the exact list of characters that are allowed (or disallowed) for a username in Keycloak. During my investigation, I came across the file`src/main/java/org/keycloak/services/validation/Validation.java`and this specific line: `Pattern.compile("^[\\p{IsLatin}|\\p{IsCommon}]+$")`

I’m particularly curious about the `\p{IsCommon}`part of this regular expression. It doesn’t seem to match any standard class documented in the Java Regular Expressions API (see [Pattern (Java Platform SE 8 )](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)), and I couldn’t find a clear explanation of what it encompasses.

1. Does `\p{IsCommon}`represent a Keycloak-specific extension, or does it map to a broader Unicode class? Is there an exhaustive list of characters that fall under this category?
2. And more globally, is there an exhaustive list of allowed characters for usernames in Keycloak ? If so, is it possible to access or retrieve this list?

Thank you in advance for your insights!

---

<div class="post-metadata">

**Author:** ![dteleguin](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dteleguin/32/11917_2.png) [@dteleguin](https://forum.keycloak.org/u/dteleguin)\
**Post date:** [January 24, 2025, 12:22am UTC](https://forum.keycloak.org/t/what-is-the-list-of-allowed-characters-for-usernames-in-keycloak/29468/2 "2025-01-24T00:22:48Z")

</div>

Hi Catheline,

1. The `\p{IsCommon}` construct refers to the “Common” Unicode script. Therefore, the “Latin”[1] and “Common”[2] scripts together comprise the whitelist;
2. Keycloak 24 has [introduced](http://www.keycloak.org/2024/03/keycloak-2400-released.html) the User Profile feature with fine-grained, per attribute validators. It applies an additional [blacklist](http://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/userprofile/validator/UsernameProhibitedCharactersValidator.java#L44) of characters on top of the above whitelist.

That said, the resulting allowlist looks like this (let’s use Unicode 🙂 ):

```auto
(UnicodeLatin ∪ UnicodeCommon) ∖ UsernameProhibitedCharacters

```

[1] zuga .net/articles/unicode/script/latin/  
[2] zuga .net/articles/unicode/script/common/

---

<div class="post-metadata">

**Author:** ![dteleguin](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dteleguin/32/11917_2.png) [@dteleguin](https://forum.keycloak.org/u/dteleguin)\
**Post date:** [January 24, 2025, 12:32am UTC](https://forum.keycloak.org/t/what-is-the-list-of-allowed-characters-for-usernames-in-keycloak/29468/3 "2025-01-24T00:32:33Z")

</div>

(sorry for the formatting, seems like a bug in Discourse doesn’t allow to post direct links sometimes)

---

<div class="post-metadata">

**Author:** ![Catheline](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/catheline/32/11915_2.png) [@Catheline](https://forum.keycloak.org/u/Catheline)\
**Post date:** [January 24, 2025, 9:18am UTC](https://forum.keycloak.org/t/what-is-the-list-of-allowed-characters-for-usernames-in-keycloak/29468/4 "2025-01-24T09:18:45Z")

</div>

Hi Dimitry,

Thank you so much for your detailed and helpful explanation! I really appreciate the time you took to clarify this. No worries about the links, I was able to access them, and they were exactly what I was looking for.

Catheline
