[GH-ISSUE #1587] Keycloak Invalid RealmID #2716

Open
opened 2026-08-05 00:48:33 -04:00 by saavagebueno · 2 comments
Owner

Originally created by @JonnyBDev on GitHub (Feb 15, 2024).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/1587

Describe the problem
We had some trouble setting up Netbird with Keycloak. After some testing we've found out that a RealmID with a space in it will result in Netbird not being able to "warm up cache" and not running as expected at all.

We did not use the RealmID "netbird" as suggested in the docs because our users are stored in the company default Realm "Company GmbH". This will result in an escaped url which looked like this for the admin endpoint:
https://id.customerdomain.tld/admin/realms/company%20gmbh

As I said using this RealmID, we couldn't get Netbird running. Connecting to the UI worked, but it showed a 401 token invalid error message. After renaming the RealmID from "Company GmbH" to "companygmbh", without changing any credentials only the urls, it worked.

To Reproduce

Steps to reproduce the behavior:
Follow the advanced Guide to setup a selfhosted instance with Keycloak.

Expected behavior

Netbird should work with all kinds of RealmIDs

NetBird version
0.25.5

Originally created by @JonnyBDev on GitHub (Feb 15, 2024). Original GitHub issue: https://github.com/netbirdio/netbird/issues/1587 **Describe the problem** We had some trouble setting up Netbird with Keycloak. After some testing we've found out that a RealmID with a space in it will result in Netbird not being able to "warm up cache" and not running as expected at all. We did not use the RealmID "netbird" as suggested in the docs because our users are stored in the company default Realm "Company GmbH". This will result in an escaped url which looked like this for the admin endpoint: `https://id.customerdomain.tld/admin/realms/company%20gmbh` As I said using this RealmID, we couldn't get Netbird running. Connecting to the UI worked, but it showed a 401 token invalid error message. After renaming the RealmID from "Company GmbH" to "companygmbh", without changing any credentials only the urls, it worked. **To Reproduce** Steps to reproduce the behavior: Follow the advanced Guide to setup a selfhosted instance with Keycloak. **Expected behavior** Netbird should work with all kinds of RealmIDs **NetBird version** 0.25.5
saavagebueno added the bugtriage-neededkeycloakself-hosting labels 2026-08-05 00:48:34 -04:00
Author
Owner

@surik commented on GitHub (Feb 15, 2024):

Hi @JonnyBDev, we just made a short validation with Keycloak 23. It doesn't allow us to have any special characters in the realm name. See screenshot.

Can you give a bit more information about your setup? Some things that may help:

  1. Keycloack version
  2. Was the realm created on some older version
  3. What do you see if you go to the realm setting and check the URL shown in the browser, eg: http://localhost:8080/admin/master/console/#/test1/realm-settings. Where test1 is the realm name/id.
image
<!-- gh-comment-id:1946504817 --> @surik commented on GitHub (Feb 15, 2024): Hi @JonnyBDev, we just made a short validation with Keycloak 23. It doesn't allow us to have any special characters in the realm name. See screenshot. Can you give a bit more information about your setup? Some things that may help: 1. Keycloack version 2. Was the realm created on some older version 3. What do you see if you go to the realm setting and check the URL shown in the browser, eg: `http://localhost:8080/admin/master/console/#/test1/realm-settings`. Where `test1` is the realm name/id. <img width="1208" alt="image" src="https://github.com/netbirdio/netbird/assets/708165/1189debf-437b-423f-9f15-3db0ef1b0754">
Author
Owner

@PizzaLovingNerd commented on GitHub (May 30, 2026):

Realm IDs containing spaces are problematic upstream in Keycloak itself and are not a NetBird-specific URL construction issue. Please use a URL-safe Keycloak realm ID. Closing as an upstream limitation. Thanks!

<!-- gh-comment-id:4585479965 --> @PizzaLovingNerd commented on GitHub (May 30, 2026): Realm IDs containing spaces are problematic upstream in Keycloak itself and are not a NetBird-specific URL construction issue. Please use a URL-safe Keycloak realm ID. Closing as an upstream limitation. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#2716