Keycloak Knowledge Patch
Use this skill when configuring, extending, integrating, administering, or upgrading Keycloak. Start with the breaking-change checks below, then open the topic reference that matches the task.
Reference index
| Reference | Topics |
|---|---|
| Admin and Account APIs | Client Admin API v2, Account REST permissions and consent, fine-grained administration fixes |
| Authentication and Token Exchange | Authentication flows, LoA and AMR, token exchange, WebAuthn, DPoP, AuthZEN, ID-JAG |
| Identity, Brokering, and Organizations | Identity providers, organizations, SCIM, OID4VCI, SSF, redirects, logout delivery |
| Client, Theme, and Extension Migrations | Themes, Keycloak JS, User Profile, token shape, SPIs, Java extension compatibility |
| Deployment and Storage Migrations | Persistent sessions, caches, databases, trust, proxying, Operator, clustering |
| Server Configuration and Operations | Environment mapping, optimized builds, readiness, queues, metrics, secrets, bootstrap |
Breaking-change triage
Preserve sessions before crossing into 26
- Upgrade through 25 and enable preview
persistent-user-sessionson that first upgrade. - Only sessions already backed by remote Infinispan or embedded-cache JDBC persistence can migrate.
- Do not enable persistence later and expect persisted and non-persisted sessions to merge safely.
- Expect 26 to clear caches because Protostream is incompatible with the former JBoss Marshalling format.
Replace removed hostname and proxy configuration
- Treat hostname v2 as the active model:
hostnameaccepts a host or full URL, andhostname-adminrequires a full URL. - Replace removed hostname-v1 path and port settings.
- Replace
proxywith exactly one trustedproxy-headersformat and explicit HTTP/hostname settings. - Use a full frontend URL with
hostname-backchannel-dynamic=truefor dynamic backchannel resolution.
Move caches and transactions to runtime-safe settings
- Supply
cache,cache-stack, andcache-config-fileat runtime; they are no longer build options. - Account for
transaction-xa-enabled=falseby default. - With multiple datasources, configure all but at most one as XA.
- Bound custom session-cache definitions consistently with the standard configuration.
Update themes and browser clients
- Migrate welcome themes from PatternFly 3 to 5 and Account Console themes from
keycloak.v2tokeycloak.v3. - Replace shared
node_modules/...theme paths with the appropriatevendor/...path; bundle Alpine.js or jQuery when needed. - Import from
keycloak-jsorkeycloak-js/authz; the server no longer serves the library and the global UMD build is gone. - Pass adapter configuration explicitly and await
login(),createLoginUrl(), andcreateRegisterUrl().
Audit identity and token compatibility
- Use dedicated identity-provider endpoints for normal realm reads; only exports embed identity providers.
- Treat an identity-provider alias as immutable after creation.
- Attach compatibility mappers when clients still require
session_statein tokens ornonceafter refresh. - Use standards-based RP-Initiated Logout; legacy logout
redirect_uribehavior is removed. - Update custom code that assumed
UserRepresentation.getAttributes()included root user fields.
Rework removed and renamed extension APIs
- Replace token convenience setters
expiration,notBefore, andissuedAtwithexp,nbf, andiat. - Pass
Config.ScopetoEnvironmentDependentProviderFactory.isSupported. - Do not restart a request's
KeycloakSessiontransaction; a transaction may be started only once. - Give asynchronous REST work its own session and transaction lifecycle.
- Update event listeners for credential events and realm deletion behavior.
Plan large-schema migrations
- Inspect startup output for manual index SQL when affected tables exceed 300,000 rows.
- Run the emitted statements after startup; do not assume automatic migration created those indexes.
- Check
USER_ATTRIBUTE,FED_USER_ATTRIBUTE,RESOURCE_SERVER_PERM_TICKET, andIDENTITY_PROVIDERaccording to the upgrade path.
Security-critical checks
Apply post-release security fixes
- Use the 26.7.2 fixes when account linking or reset-credentials flows are exposed; both received account-takeover corrections.
- Ensure Admin REST does not expose vault-resolved rotated secrets and
show-configdoes not reveal the vault keystore password. - Verify disabling client-secret rotation invalidates the rotated secret.
- Confirm fine-grained permissions protect Role Groups, hidden group parents, and parameterized user-property mappings.
Harden redirects and browser requests
- Prefer exact, case-sensitive redirect URIs.
- Never use the full
*redirect pattern in production. - Know that userinfo and
/../paths force exact matching even when a trailing wildcard is configured. - Protect browser-carried LoA requests with PAR or a request object, and verify the returned
acr.
Anchor credentials and sender constraints
- Configure the X.509 client's exact Certificate Authority subject DN; regex matching is deprecated.
- Use HAProxy
ssl-cert-chain, notssl-cert-chain-prefix. - Exchange DPoP- or mTLS-bound tokens only as the original client with the corresponding proof or certificate.
- Reject implicit and hybrid flows for clients requiring DPoP-bound tokens.
Protect legacy token exchange
- Prefer standard token exchange v2 for same-realm Keycloak access tokens.
- Keep public clients out of v2; confidential requesters must authenticate and explicitly enable the capability.
- Treat legacy v1 as deprecated and narrowly authorize its
token-exchangepermission. - Do not rely on legacy external JWT exchange to validate
aud.
High-value authentication guidance
Configure standard token exchange v2
- Enable Standard token exchange on the confidential requester.
- Authenticate the requester at the token endpoint.
- Send a same-realm Keycloak access token as
subject_token. - Request an access token, ID token, or permitted refresh token.
- Use
audienceonly to filter already-resolved audiences; it cannot add one. - Apply
downscope-assertion-grant-enforcerwhen requested scopes must be bounded by the subject token.
V2 does not support RFC 8693 resource, never creates a new user session, and requires the requester in the subject token's aud unless the token was issued to that requester.
Build passkey-aware conditional 2FA
- Combine Condition - User Configured with Condition - credential in the conditional 2FA branch.
- The credential condition skips 2FA after passwordless WebAuthn already authenticated the user.
- Make WebAuthn and recovery codes Alternative when configured users should see them under Try Another Way.
- Use
required,preferred, ordiscouragedfor discoverable credentials; the former boolean option is deprecated.
Express LoA and AMR correctly
- Order Conditional - Level Of Authentication subflows from lowest to highest.
- Remember the first LoA subflow always runs on initial authentication.
- Use an essential
claimsrequest when the level must be enforced;acr_valuesis only advisory. - Map successful execution references into
amrwith the AMR protocol mapper. - Use Client Policies and
AuthenticationFlowSelectorExecutorwhen flow and level selection depend on client conditions.
Place the session limiter safely
- Put User Session Count Limiter after the user is known in Browser, Direct Grant, Reset Credentials, and Post Broker flows.
- Reuse one consistent configuration.
- In Browser, put it inside an alternative real-authentication branch alongside the top-level Cookie execution so SSO-cookie reuse is not counted again.
- Choose whether overflow denies the new session or terminates the oldest;
0disables the relevant limit. - Do not design around this authenticator for CIBA, where it is unavailable.
High-value API and identity features
Use Client Admin API v2 deliberately
- Enable
client-admin-api:v2for strictly validated declarative OIDC and SAML client management. - Use REST, Java, generated JavaScript, CLI, or the management-interface OpenAPI document.
- Filter collections with the supported SCIM subset and project fields only after filtering.
- Expect HTTP 400 for malformed expressions, unknown fields, or ordering operators.
Choose the right identity capability
- Enable
scim-apifor preview user/group CRUD, PATCH, filtering, pagination, Enterprise User extensions, and schema discovery. - Enable
identity-assertion-jwtwhen Keycloak must receive a signed identity assertion and issue an access token without another login. - Enable
authzenfor single or batch permit/deny policy evaluations. - Enable
ssfto transmit signed CAEP or RISC Security Event Tokens over push or poll delivery. - Enable
statelessfor multi-cluster v2's embedded caches and database-backed invalidation outbox.
Administer organizations safely
- Assign
manage-organizations,view-organizations, orquery-organizationsfor coarse-grained access. - Require
view-usersor equivalent fine-grained permission before viewing members. - Use organization-specific fine-grained permissions for scoped access.
- Expect organization group roles in members'
realm_accessandresource_accessclaims. - Enable Add group role mappings to group those roles by organization in the
organizationclaim.
High-value operational guidance
Preserve exact environment values
- Use
KCRAW_instead ofKC_when dollar characters and${...}must remain literal. - Never define both raw and evaluated forms for the same key.
- Pair
KC_<suffix>withKCKEY_<suffix>when normalization cannot represent the exact option key.
Keep optimized builds reproducible
- Never place secrets in build options; every build option is persisted in plaintext.
- Under
start --optimized, repeated matching build options are ignored and differing values are rejected. - Rebuild to change a build option.
- Normalize provider JAR modification times before
kc.sh buildin container images.
Gate traffic on readiness
- With health enabled, startup and liveness may be UP while initialization continues.
- Route traffic only when
/health/readyis UP. - Set
server-async-bootstrap=falsewhen endpoints must remain closed until initialization finishes. - Set
http-max-queued-requeststo bound waiting requests; excess requests receive HTTP 503.
Working method
- Identify whether the task concerns integration behavior, authentication, an API, an extension, or deployment.
- Run the relevant breaking-change and security checks above.
- Open the matching reference file and apply all constraints for that topic.
- Prefer explicit feature names and exact option keys over assumptions based on older defaults.
- Test migrations against representative realms, sessions, custom providers, themes, and client token expectations.