Keycloak
Keycloak is an open-source Identity and Access Management solution maintained by Red Hat. It provides single sign-on, social login, user federation, fine-grained authorization, and supports OpenID Connect, OAuth 2.0, and SAML 2.0 protocols.
Connector Setup (Recommended)
Add Keycloak as a connector to the embedded IdP. This is the simplest approach and recommended for most deployments.
Prerequisites
- NetBird self-hosted with embedded IdP enabled
- Keycloak instance running with SSL
Step 1: Create Client in Keycloak
- Open the Keycloak Admin Console
- Select your realm (or create a new one, e.g.,
netbird) - Click Clients → Create client
- Fill in the form:
- Client type:
OpenID Connect - Client ID:
netbird
- Client type:
- Click Next
- On Capability config:
- Enable Client authentication
- Click Next
- On Login settings:
- Leave redirect URIs empty for now
- Click Save
- Go to the Credentials tab and copy the Client secret
Step 2: Add Connector in NetBird
- Log in to your NetBird Dashboard
- Navigate to Settings → Identity Providers
- Click Add Identity Provider
- Fill in the fields:
| Field | Value |
|---|---|
| Type | Generic OIDC |
| Name | Keycloak (or your preferred display name) |
| Client ID | netbird (from Step 1) |
| Client Secret | From Keycloak Credentials tab |
| Issuer | https://keycloak.example.com/realms/your-realm |
- Click Save
Step 3: Configure Redirect URI
After saving, NetBird displays the Redirect URL. Copy this URL and add it to your Keycloak client:
- Return to Keycloak Admin Console
- Go to your client → Settings tab
- Under Valid redirect URIs, add the redirect URL from NetBird
- Click Save
Step 4: Test the Connection
- Log out of NetBird Dashboard
- On the login page, you should see a "Keycloak" button
- Click it and authenticate with your Keycloak credentials
- You should be redirected back to NetBird and logged in
Users who authenticate via Keycloak will appear in your NetBird Users list with a Keycloak badge next to their name.
Standalone Setup (Advanced)
Use Keycloak as your primary identity provider instead of NetBird's embedded IdP. This option gives you full control over authentication and user management, is recommended for experienced Keycloak administrators as it also requires additional setup and ongoing maintenance.
For most deployments, the embedded IdP is the simpler choice — it's built into NetBird, fully integrated, and requires minimal configuration to get started. For this implementation, go back up to the Connector Setup (Recommended) section above.
If you prefer not to self-host an Identity and Access Management solution, you could use a managed alternative like Auth0.
Expected Result
After completing this guide, you can log in to your self-hosted NetBird Dashboard and add machines to your network using the Interactive SSO Login feature over Keycloak.

Prerequisites
- Keycloak instance running with SSL
- Docker and Docker Compose for NetBird
Step 1: Check Your Keycloak Instance
Ensure your Keycloak instance is available at https://YOUR-KEYCLOAK-HOST-AND-PORT with SSL enabled.
Step 2: Create a Realm
- Open the Keycloak Admin Console
- Hover over the dropdown in the top-left corner where it says
Master - Click Create Realm
- Fill in:
- Realm name:
netbird
- Realm name:
- Click Create

Step 3: Create a User
- Make sure the selected realm is
netbird - Click Users (left-hand menu)
- Click Create new user
- Fill in:
- Username:
netbird
- Username:
- Click Create

- Click Credentials tab
- Click Set password
- Fill in the password and set Temporary to
Off - Click Save

Step 4: Create NetBird Client
- Click Clients → Create client
- Fill in:
- Client Type:
OpenID Connect - Client ID:
netbird-client
- Client Type:
- Click Next

- Enable the authentication options as shown:

- Click Save
Step 5: Configure Client Access Settings
- Go to Clients → netbird-client
- In Access Settings, fill in:
- Root URL:
https://YOUR_DOMAIN/ - Valid redirect URIs:
https://YOUR_DOMAIN/*andhttp://localhost:53000 - Valid post logout redirect URIs:
https://YOUR_DOMAIN/* - Web origins:
+
- Root URL:
- Click Save

Step 6: Create Client Scope
- Click Client scopes (left-hand menu)
- Click Create client scope
- Fill in:
- Name:
api - Type:
Default - Protocol:
OpenID Connect
- Name:
- Click Save

- Switch to the Mappers tab
- Click Configure a new mapper
- Choose Audience mapping

- Fill in:
- Name:
Audience for NetBird Management API - Included Client Audience:
netbird-client - Add to access token:
On
- Name:
- Click Save

Step 7: Add Client Scope to NetBird Client
- Go to Clients → netbird-client
- Switch to Client scopes tab
- Click Add client scope
- Choose
api - Click Add choosing
Default

Step 8: Create NetBird-Backend Client
- Click Clients → Create client
- Fill in:
- Client Type:
OpenID Connect - Client ID:
netbird-backend
- Client Type:
- Click Next

- Enable authentication as shown:

- Click Save
- Go to Credentials tab
- Copy the Client secret

Step 9: Add View-Users Role
- Go to Clients → netbird-backend
- Switch to Service accounts roles tab
- Click Assign roles
- Select Filter by clients and search for
view-users

- Check the role checkbox and click Assign

Optional: To enable automatic user deletion from Keycloak when deleted from NetBird, add the --user-delete-from-idp flag to the management startup command and assign the manage-users role instead.
Step 10: Configure NetBird
Your authority OIDC configuration will be available at:
https://<YOUR_KEYCLOAK_HOST_AND_PORT>/realms/netbird/.well-known/openid-configuration
Double-check if the endpoint returns a JSON response by calling it from your browser.
Set properties in the setup.env file:
NETBIRD_AUTH_OIDC_CONFIGURATION_ENDPOINT="https://<YOUR_KEYCLOAK_HOST_AND_PORT>/realms/netbird/.well-known/openid-configuration"
NETBIRD_USE_AUTH0=false
NETBIRD_AUTH_CLIENT_ID="netbird-client"
NETBIRD_AUTH_SUPPORTED_SCOPES="openid profile email offline_access api"
NETBIRD_AUTH_AUDIENCE="netbird-client"
NETBIRD_AUTH_DEVICE_AUTH_CLIENT_ID="netbird-client"
NETBIRD_AUTH_DEVICE_AUTH_AUDIENCE="netbird-client"
NETBIRD_MGMT_IDP="keycloak"
NETBIRD_IDP_MGMT_CLIENT_ID="netbird-backend"
NETBIRD_IDP_MGMT_CLIENT_SECRET="<NETBIRD_BACKEND_CLIENT_SECRET>"
NETBIRD_IDP_MGMT_EXTRA_ADMIN_ENDPOINT="https://<YOUR_KEYCLOAK_HOST_AND_PORT>/admin/realms/netbird"
Make sure your Keycloak instance uses HTTPS. Otherwise, the setup won't work.
Step 11: Continue with NetBird Setup
You've configured all required resources in Keycloak. Continue with the NetBird Self-hosting Guide.
Troubleshooting
"Invalid redirect URI" error
- Ensure the redirect URI matches exactly what's configured
- For connector: Use the exact URL from the NetBird success modal
- For standalone: Include both
https://YOUR_DOMAIN/*andhttp://localhost:53000
"Invalid token" errors
- Verify the issuer URL includes
/realms/your-realm - Ensure the client ID matches in both Keycloak and NetBird
- Check clock synchronization between servers
Users not appearing in NetBird
- For connector: Users appear after their first successful login
- For standalone: Verify the backend client has
view-usersrole

