Connect NetBird to Keycloak
Connect NetBird and Keycloak with the current self-hosted identity model, explicit peer policies and separate account, device and network revocation checks.
Last updated
In short
- User authentication and peer network authorization are separate decisions.
- Current embedded-IdP setups differ from older direct-provider deployments.
- Offboarding must test existing devices and active network connections.
On this page (7)
Integrations · Part of NetBird
Match the guide to the NetBird identity architecture
NetBird’s current self-hosted documentation supports adding Keycloak through the Management Dashboard when the embedded identity provider is enabled. Older deployments can use a different direct-provider architecture. Mixing instructions from those two arrangements can produce incorrect redirect URIs, duplicated users or an unusable login flow.
This is a documented reference procedure, not a tested deployment. Start with the current self-hosted Keycloak guide and record NetBird management, dashboard and client versions, the embedded-IdP setting and the Keycloak release. Use the documentation branch appropriate to that configuration.
Separate user, device and network permission
A person authenticates through Keycloak. A device becomes a NetBird peer through the approved enrollment process. Access policies then determine which resources that peer may reach. These are related but different states.
| Layer | Question | Evidence |
|---|---|---|
| Identity | May this person sign in? | Issuer, client and assignment checks |
| Enrollment | May this device join the network? | User/device approval record |
| Group membership | Which user and peer groups apply? | Effective membership inspection |
| Network policy | Which destination and ports are allowed? | Positive and negative connection tests |
| Offboarding | What terminates existing access? | Account, peer and active-session observations |
The NetBird policy documentation distinguishes user groups, peer groups and access rules. A group claim arriving from Keycloak is not sufficient evidence that the resulting network policy is correct. Review effective memberships and any existing broad policies before adding real resources.
Configure a dedicated identity client
For the embedded-IdP arrangement, follow the Management Dashboard procedure to obtain the required callback and provider settings. Register the exact redirect URI in Keycloak and use the intended HTTPS realm issuer. Ensure NetBird’s server can reach that issuer and trusts its certificate, including the internal certificate authority if one is used.
| Item | Required record | Failure to test |
|---|---|---|
| Realm issuer | Exact HTTPS URL | Wrong realm accepted or discovery unreachable |
| Client identity | Dedicated NetBird client | Unrelated client credential reused |
| Callback | Exact URI for chosen architecture | Loop or redirect mismatch |
| Claims | Stable subject and required profile information | Email change creates duplicate user |
| Recovery access | Approved local or alternative administrator route | Identity outage locks out operators |
| Client flow | Browser/device behavior used by selected clients | Desktop enrollment fails despite dashboard login |
Keep the client credential in the deployment’s secret-management process. Do not copy a server-side secret into a public desktop-client configuration unless the current product documentation explicitly defines that use; public and confidential client flows have different security models.
Check provisioning and licensing separately
Authentication can work without automatic directory synchronization. Decide how users are created, how groups update and what removes them. The Keycloak provisioning guide distinguishes deployment arrangements and points self-hosted embedded-IdP commercial deployments to the applicable variant.
Confirm the edition and commercial entitlement required for the synchronization features you intend to use. Do not promise automatic group provisioning or offboarding based only on a successful OIDC login. Record the synchronization interval and failure behavior if that integration is part of the design.
Build a two-resource pilot
Create two harmless destinations: an engineering test service and an administration test service. Enroll one engineering device and one unassigned device. Give the engineering peer access only to the intended service and port; reserve the administration service for a separately controlled group.
| Test | Expected result |
|---|---|
| Engineering peer reaches approved service | Connection succeeds on the permitted port |
| Engineering peer reaches administration service | Connection denied |
| Unassigned peer reaches either service | Denied under the intended policy |
| Engineering peer scans another port | Denied unless explicitly permitted |
| User signs into dashboard | Receives only intended management role |
| Device enrolls through an alternate method | Same approval and policy boundary applies |
Test actual network traffic rather than relying only on a policy screen. Include routed resources, DNS behavior and any setup-key enrollment path in the scope. A reusable setup key can have a different lifecycle from a person authenticating through SSO.
Measure revocation on an already-connected device
Remove the user’s group, disable their Keycloak account and revoke the peer in separate exercises. Observe the existing connection and a newly attempted connection after each action. Record how policy propagation, login expiry and device revocation interact in the selected versions.
If a device is offline during the change, test its return. If the management service is unavailable, document the behavior of established connectivity. Do not equate “fresh login denied” with “all previously enrolled devices immediately disconnected.” The offboarding procedure must use the controls that actually satisfy the organization’s access-removal requirement.
Back up identity and network policy together
Preserve the NetBird management state, identity configuration, policy definitions and required keys under the supported backup procedure. Keep Keycloak’s realm and client recovery process coordinated with it. Restore into an isolated environment to avoid competing management endpoints or unexpected peer reassociation.
Before changing identity architecture, retain a reviewed rollback plan and mapping of existing users and peers. Reverting a provider URL does not automatically undo newly created identities. Acceptance requires correct enrollment, narrow resource access, measured revocation and a recovery path that keeps administrators in control of the network.
Sources and further reading
Use the linked documentation to confirm the version, edition and contract that apply to your project.
