Keycloak: what it does and what you must operate yourself
Understand realms, clients, roles, identity brokering, and the production responsibilities of running Keycloak.
Keycloak is an open-source identity and access management server that an organization can run itself. It authenticates users and issues tokens or SAML assertions to apps that support OpenID Connect (OIDC) or SAML. Self-hosting offers flexibility, but the organization must operate servers, database, TLS, public URLs, availability, updates, and backups.
This overview reflects current Keycloak administration and operations documentation checked on 2026-11-19. Configuration options can change between releases; use documentation for the deployed version before changing settings.
Realms, clients, users, and roles
A realm is a logical area that holds users, credentials, groups, roles, clients, and authentication settings. Users sign in to a particular realm. A client is a web app, mobile app, or service that requests authentication. Its client ID, redirect URI, and protocol settings need to match the app.
A common sign-in flow is:
The app redirects the user to the realm’s Keycloak login page.
Keycloak authenticates the user through a local account or a connected external identity provider.
Keycloak returns an authorization code and tokens, or a SAML response, according to the client configuration.
The app validates issuer, signature, audience, time claims, and request correlation.
The app applies the verified identity and roles to its own access policy.
Realm roles can represent organization-wide roles shared across apps; client roles can be specific to one app. Groups can bundle users and attributes. Which roles appear in a token or SAML assertion depends on client scopes and protocol mappers. Check the claims the app actually receives instead of assuming a successful login includes every permission.
Connect directories and external identity providers
User federation can connect LDAP or Active Directory as an external user store. Identity-provider brokering instead delegates authentication to an external OIDC/SAML provider or social provider and maps the incoming identity to a Keycloak account and session. These are distinct integrations.
For each connection, decide which system can create or change user attributes, whether users are imported locally or looked up remotely, and how group/role mapping works. Imported and non-imported users can behave differently in searches and administration. Do not turn an external claim directly into an administrator role without restricting the trusted issuer and allowed values.
Application roles versus Keycloak admin roles
Application roles describe what a user can do inside an app. Administrative roles determine who can change Keycloak users, clients, roles, or realm settings. Confusing these layers can give an app operator control of the identity server.
Keycloak distinguishes server-level administrators, realm administrators, and delegated fine-grained permissions. A server administrator can manage multiple realms; a realm administrator is scoped to permitted realms. Fine-grained delegation can limit access to selected resources or actions, but broad higher-level roles may bypass those limits. Review powerful assignments in the master realm and each realm regularly.
Production operating boundaries
Production traffic must use HTTPS/TLS. Separate public OIDC endpoints from the admin console and Admin REST API, and use proxy/network controls so administrative surfaces are not unnecessarily exposed.
Configure a fixed external hostname and trusted proxy headers. If Keycloak builds external URLs from untrusted Host headers, an attacker may induce incorrect issuer or password-reset links. The hostname is therefore a trust setting, not just a display preference.
Plan for a supported database and tested backup/restore; cluster communication, distributed cache, load balancing, and health checks if multiple instances are needed; least-privilege administrator access; and monitoring for Keycloak, database, TLS certificate, and external IdP metadata expiry. Troubleshoot by separating app/client settings, realm policy, identity provider, token validation, proxy, and server logs.
If an external app rejects a token, check the realm issuer URL, client ID, redirect URI, signing-key/JWKS refresh, and token audience before recreating users. If Keycloak login succeeds but the app lacks an expected identity or role claim, inspect client scopes and protocol mappers.
Development start-dev settings are for experimentation, not production. Before launch, follow the deployed version’s production guidance for TLS, hostname, exposure, database, administrator access, and backups. No Keycloak instance was configured or tested for this article.
Sources
[Keycloak Server Administration Guide](https://www.keycloak.org/docs/latest/server_admin/)
[Configuring Keycloak for production](https://www.keycloak.org/server/configuration-production)
[Configuring the hostname](https://www.keycloak.org/server/hostname)
[Configuring TLS](https://www.keycloak.org/server/enabletls)
[Securing applications and services with OpenID Connect](https://www.keycloak.org/securing-apps/oidc-layers)