Keycloak client authentication and client secret rotation: when your team needs it
Your Keycloak realm probably has confidential clients whose secrets were set when the application was first connected and have not changed since. This page covers how to rotate client secrets safely, and how to replace shared secrets with signed JWT or mutual TLS (mTLS) client authentication where your applications and infrastructure can support it. A confidential client is an application that can keep a credential private, such as a server-side web app or a back-end service, as opposed to a public client like a single-page app or mobile app that cannot. Confidential clients prove who they are when they call the token endpoint, typically by exchanging an authorization code or refresh token, and that proof is what stops anyone who intercepts a code from redeeming it. If the proof is a long-lived shared secret, anyone who copies it from a config file, a CI variable or an old backup can impersonate the application.
The decision starts with an inventory. Ask which clients use the client secret method, when each secret was last changed, who holds a copy, and where it is stored. Many teams find secrets in deployment manifests, shared password managers or former contractors' notes. For each client, decide whether the secret should simply be rotated on a schedule, or whether the client should move to signed JWT (private key JWT) or mTLS authentication, which removes a shared value from the wire and from the Keycloak database. The migration cost depends mostly on the client library and the platform in front of it, since not every framework supports both methods, so confirm support in your own stack before committing to a method.
A rotation runbook matters because a secret change breaks every replica still using the old value. Plan an overlap window in which the application accepts the new secret while the old one is retired, deploy to all instances, and check token issuance and refresh flows before revoking the old value. Confirm with your application owners how their libraries load secrets and whether a restart is needed. Keycloak's own documentation covers the client credential settings and the authentication methods available per client, and the Keycloak server administration guide is the natural next read to confirm which method each of your clients can use.
Client authentication options and when each fits
This table compares the three ways a confidential client can prove its identity to Keycloak at the token endpoint: a shared client secret, a signed JWT, and mutual TLS. Read each row across the columns to see what the client holds, what Keycloak stores, and what rotation and distribution cost. The main takeaway is that the stronger methods remove the shared secret but add certificate or key operations, so confirm the exact authenticator names and settings in the administration guide for your release before you configure them.
| Aspect | Client secret | Signed JWT (private key JWT or client secret JWT) | mTLS client authentication |
|---|---|---|---|
| What the client holds | A shared secret string copied into the application configuration | A private key (private key JWT) or the shared secret used to sign a short-lived assertion (client secret JWT) | A client certificate and its private key, presented during the TLS handshake |
| What Keycloak stores | The secret value or its reference in the client settings | The public key or certificate material for the client, registered through JWKS or a certificate setting | The trusted certificate or CA chain used to validate the client certificate |
| Rotation effort | Low per client, but every rotation must reach each place the secret is used | Moderate: publish a new public key alongside the old one, then switch the client over | Higher: issue, distribute and renew certificates, and update trust settings before expiry |
| Operational dependencies | Secret storage in the application and deployment pipeline | JWKS reachability or key registration, clock accuracy for assertion lifetimes, key storage on the client | Proxy or load balancer must pass the client certificate through to Keycloak, plus a certificate authority process |
| Suits which clients | Legacy or low-risk confidential clients where stronger options are not yet supported by the application | Backend services and workloads that can sign assertions and manage keys in a vault or HSM | Service-to-service clients in environments that already run a certificate authority and mutual TLS |
| Confirm before you configure | Secret length and generation policy you enforce in your pipeline | Exact authenticator name, accepted signing algorithms and the JWKS or key setting for your release | Exact authenticator name, proxy header settings and certificate validation options for your release |
How to inventory clients and rotate secrets without breaking sign-in
This sequence moves confidential clients from long-lived shared secrets toward a planned, verified rotation cycle, so each secret change is tested in parallel before the old one is retired. The result is an inventory of which clients still rely on client secrets, a rotation interval for each risk tier, and evidence that sign-in and token refresh keep working after every change.
Export the confidential client inventory
The Keycloak administrator exports the list of clients in each realm and filters for confidential clients, recording the client ID, owning team, environment, protocol and the client authenticator type shown in the client's credentials tab. Keep the export in version control or your configuration record so later steps can compare against it. Done means every confidential client in every realm appears in one list with an owner named, and any client with no owner is flagged for follow-up before rotation begins.
Identify clients still using client secrets
Using the inventory, the administrator separates clients that authenticate with a client secret from those already using signed JWT or mutual TLS (mTLS) client authentication. For each secret-based client, the team records when the secret was last changed, if that date is known, and whether the secret is also stored in application configuration, a container image, a CI variable or a shared password manager entry. Done means every secret-based client has a documented location for its secret, which becomes the list of places to update during rotation.
Assign a rotation interval by risk tier
The security owner groups clients into risk tiers based on what they can access, whether they handle regulated data, and how widely the secret is distributed. Each tier receives a rotation interval written into the client standard, and clients that cannot yet move to signed JWT or mTLS are listed with a planned migration date. Confirm the interval against your own policy and any framework your auditors test, since the Keycloak documentation does not set a required interval. Done means each client has a tier and an interval recorded in its owner's record.
Confirm dual-secret support in each application
Before any secret changes, the application team checks whether its OIDC or OAuth library can hold two client secrets at once, or can read a new secret from configuration without a restart. This varies by library and framework, so confirm it for each application against that library's own documentation and a test in a non-production environment. Where an application cannot accept a second secret, plan a short maintenance window instead of a parallel overlap. Done means every client in the rotation batch has a recorded answer on overlap support and a test result.
Generate and stage the new secret
The administrator generates a new client secret for the client and the application team deploys it to the staging or pre-production environment alongside the existing secret where overlap is supported. Keep the new secret in the approved secret store rather than in the client record or a ticket. Done means the application in the test environment has the new secret loaded, and a test sign-in succeeds using it, with the change recorded in the rotation log.
Rotate in production and verify token issuance and refresh
The team deploys the new secret to production in the order agreed during planning, then checks that new logins complete, that the token endpoint issues access and ID tokens, and that refresh token exchanges succeed for sessions that started before the change. Watch the Keycloak event log and the application's error logs during this window. Done means a complete login, a token refresh and a backend token request have each succeeded on the production client after the change, with the results written into the rotation record.
Retire the old secret and record the evidence
Once the application is confirmed to use only the new secret, the administrator removes or invalidates the old one and deletes any copies from configuration, CI variables and password managers. The team updates the inventory with the new rotation date, the next due date from the risk tier, and a link to the test and verification records. Done means the old secret no longer works, the inventory shows the new date for each rotated client, and the evidence is stored where internal auditors can find it.
Schedule recurring review of secret-based clients
The team sets a recurring review of the inventory that flags any secret-based confidential client past its rotation date and any client that has not yet moved to signed JWT or mTLS. Repeat the earlier steps for each due client, and track progress toward the migration plan for clients that must stay on secrets for now. Done means the review produces a current list of overdue and planned clients, and the owners of each have acknowledged their dates.
How a client moves from shared secret to signed JWT authentication
The flow starts with the application still sending its client secret to the Keycloak token endpoint. Teams first inventory which confidential clients use that secret, then register a signing key or certificate for each client in Keycloak. Once a test token request succeeds with the new method, the old secret is removed. The trust boundary sits between the application's own runtime and Keycloak, so the private key never leaves the application side.
Phased move from a client secret to signed JWT client authentication across the trust boundary.
Security risks in client secret handling and how to reduce them
Confidential clients prove their identity to Keycloak with a secret, a signed JWT or a client certificate, and each method fails in its own way. The cards below cover where secrets leak, how they spread across environments, who owns rotation and how to prove that rotation happened.
Secrets in application config and repositories
A client secret copied into a properties file, Helm values or a CI variable is often readable by anyone with repository access, and it stays in Git history after it is removed. Search your repositories, container images and deployment manifests for the client secret values and for the client-secret field in exported client definitions. Then confirm that each confidential client reads its secret at runtime from a secret store, and that no secret appears in build logs or images.
Secrets exposed in exports and admin screens
Realm exports, the admin console and the Admin REST API can all reveal client configuration to anyone who holds an administrator role. An export file saved to a shared drive or ticket can carry credentials that never expire. Restrict who can view and export clients, store exports only in controlled locations, and check whether your export procedure masks or omits client secrets before the file leaves the admin team.
Secrets shared across environments
When development, staging and production use the same client and secret, a weakness in a lower environment becomes a production credential exposure. Give each environment its own Keycloak client, so that a leaked test secret cannot authenticate against production. Verify this by comparing client IDs and secret fingerprints across environments, and by checking that redirect URIs differ for each environment.
No named owner for rotation
Secrets that nobody owns are rarely rotated, because rotation breaks the application that reads them and no one is accountable for the outage. Record an owning team, a rotation procedure and a rotation trigger for every confidential client, including triggers such as staff departures and suspected exposure. Verify by sampling clients and confirming that each has an owner entry in your inventory and a dated last rotation.
Certificate and key lifecycle for JWT and mTLS
Signed JWT client authentication and mutual TLS replace the shared secret with a key pair or certificate, which moves the risk to key storage, expiry and trust configuration. An expired client certificate or a retired signing key can lock a service out at a bad moment, while an unmanaged private key can be copied without anyone noticing. Confirm where each private key is held, when each certificate expires, who is alerted before expiry and how the trusted public key or certificate is replaced in the client settings.
Rotation evidence for audits
An auditor or incident responder will ask when a client credential last changed, who approved the change and whether the old credential was revoked. Admin events and a change record kept by your team can answer these questions, but only if admin event logging is enabled and the records are retained. Test this by picking one client, rotating its credential in a non-production environment and confirming that the change can be traced end to end.
How rotation differs for clients in containers, VMs and Kubernetes operators
When Keycloak runs under the Keycloak Operator, client definitions can be declared as KeycloakOIDCClient custom resources alongside the Keycloak and KeycloakRealmImport resources that the Operator also manages. The manifest then becomes the place where a client is described, so the team that owns the cluster manifests effectively owns the client. A secret rotation is a change to that declared state, and it should travel through the same review and deployment path as any other manifest change. The Operator documentation recommends manual approval mode for Operator updates, which keeps the Operator's own upgrades from landing unannounced. Keep the rotation procedure within that discipline and do not treat the secret as a value to paste into a live cluster.
- Declare the secret by reference: Keep the client secret in a Kubernetes Secret or an external secret store, and make the custom resource point to it rather than embedding the value in the manifest.
- Restrict who can edit client resources: Limit write access to KeycloakOIDCClient objects with Kubernetes RBAC, because a change to a client is a change to who can authenticate.
- Rotate through a reviewed change: Generate the new value, update the referenced Secret, and let the normal deployment path apply it, so the change has an author and a record.
- Avoid live edits: Do not edit the client in the admin console on an Operator-managed realm, since the next reconciliation may overwrite the change or leave the two sources out of step.
- Scan manifests and history: Search repositories and GitOps history for the old value after cutover, and confirm the Operator reads only the new reference.
Before relying on this model, confirm with the Operator documentation how your version reconciles client changes and whether a manual edit is reverted.
On virtual machines or in containers run from plain images, client definitions are often produced by configuration files, realm export and import, or a configuration-as-code process that the team maintains outside the running server. The source of truth is then the configuration repository and the secret store that feeds it, not the admin console. Rotation has two parts: the new value has to reach the environment that runs Keycloak, and the client's registered value in the server has to change at the same time as the consuming application. Teams that export realms for backup or migration can capture client secrets in those exports, so the export process needs the same care as the source files.
- Choose one authoritative source: Decide whether the repository or the running server is the source of truth, and disable ad hoc console edits if the repository is the answer.
- Keep secrets out of exports: Check how realm exports treat client secrets in your version and avoid committing exported files to source control.
- Inject values at deploy time: Pass the secret from a secret manager into the container or VM at start, so the repository holds a placeholder or reference.
- Coordinate the cutover: Plan a window where the server and the client application both accept the agreed sequence, then retire the old value.
- Purge old copies: Remove the previous value from configuration templates, CI variables, and any backup of the repository.
Confirm your version's import behavior for existing clients before the first rotation, since an import can overwrite a secret that was set elsewhere.
Some confidential clients are created and maintained by a product that Keycloak serves, such as a vendor application, a monitoring tool, or a platform component that registers itself through a setup wizard or installer. In this case the client definition lives partly in that product's configuration, and the product may store the secret in its own database or files. Keycloak administrators often do not know which clients are third-party owned, which makes rotation the hardest part of the topic. Ownership has to be recorded explicitly, and the vendor's documented procedure for changing a client secret has to be followed rather than improvised.
- Inventory the owner: Record for each third-party client the product, the person who manages it, and where the product stores the secret.
- Follow the vendor procedure: Ask the vendor how to rotate the secret and whether it supports signed JWT or mTLS client authentication, since many products only accept a shared secret.
- Plan for product restarts: Confirm which components must reload the new value and in what order, so the product does not fail to authenticate during the change.
- Track support boundaries: Confirm with the vendor whether changes made directly in Keycloak are supported, because an unsupported change can break the next product update.
- Keep the record current: Update the inventory after each rotation so the next person knows where the value now lives.
Before starting, confirm with each vendor which authentication methods it supports for its Keycloak client, since that determines what the hardening options are.
Limits to confirm before you commit to a rotation design
A rotation design for confidential clients depends on what your Keycloak release, your application libraries, your exports and your deployment method will actually allow. The cards below list the limits to confirm with the Keycloak documentation, your library vendors and a test realm before you commit to a runbook.
Supported client authenticator types
Confirm which client authenticator types your target Keycloak release offers for confidential clients, such as the client secret, signed JWT and X.509 certificate options. Check this against the release you plan to run, not an older version, because authenticator support and its configuration can change between minor lines. Record the exact authenticator name and where it is set on each client so the runbook matches the console you will use.
Keycloak docsLibrary support for signed JWT and mTLS
Each application library, gateway and framework that calls your token endpoint must support the client authentication method you choose. Many libraries implement only the client secret, so signed JWT or mTLS may require a custom client, a newer library version or a change in the application. Ask each vendor or maintainer in writing which methods are supported, which key formats they accept and whether they can load a rotated key without a restart.
Overlap period for old and new credentials
Find out whether your configuration can accept both the old and the new credential during a transition window. Without an overlap, every application that has not yet picked up the change will fail at its next token request. Test this in a non-production realm with a sample client, and confirm whether the client can hold two valid secrets or two trusted keys at once, and how the application stores the replacement.
Secrets in exports and backups
Determine how client secrets and client credentials appear in realm exports, partial exports, database backups and the admin REST API output. A secret that is copied into a backup or a Git repository becomes a long-lived exposure even after you rotate it. Confirm which values are masked, which are written in clear text, and who can read the export files, then plan how backups are handled during and after rotation.
Operator reconciliation of manual changes
If you manage clients with the Keycloak Operator through the KeycloakOIDCClient custom resource, confirm whether a secret or key changed in the admin console is overwritten at the next reconciliation. A rotation performed by hand can be reverted silently, which breaks applications while the console still shows the new value. Decide whether rotation happens in the custom resource or in the console, and test the reconcile behavior before you rely on it.
Operator install docsUpgrade and patch effects on clients
Check whether the upgrade path you plan changes how client authentication behaves or how the Operator manages its resources. Release notes can alter defaults, and the Operator documentation recommends manual approval for operator updates to avoid unintended automatic upgrades. Include a client authentication test in every upgrade rehearsal, so a change in authenticator behavior is found in staging rather than after a production update.
Upgrading guideQuestions teams ask before rotating Keycloak client secrets
What drives the effort of rotating secrets across many Keycloak clients?
The effort depends less on the rotation itself than on how many clients exist, how many systems hold each secret, and how much of that inventory is known. Each confidential client has a secret stored in Keycloak and copied into at least one application, pipeline, or integration, and each copy must be updated in the same change window. Teams usually underestimate the hidden consumers: batch jobs, CI variables, reverse proxies, and partner integrations that were configured years ago. Ask whether the work includes building an inventory of which clients are confidential, when each secret was last changed, and which owner can deploy the new value. Clients with shared secrets across environments add more coordination than clients with one secret per service.
Is signed JWT or mTLS client authentication worth the migration effort?
It is worth evaluating when a client handles sensitive data, runs in an environment where secrets leak easily, or sits in a group of clients that your security policy requires to be stronger. Signed JWT client authentication replaces a static shared secret with a private key the client uses to sign an assertion, so there is no reusable password to copy around. mTLS binds the client to a certificate, which fits organizations that already run a certificate authority and certificate lifecycle tooling. Confirm the exact client authentication methods your Keycloak version and client types support in its documentation, and confirm that each application library can use them. The migration cost is mostly in application changes and key or certificate lifecycle, not in Keycloak configuration.
How long does a client secret rotation take, and what sets that time?
No fixed duration applies because it depends on the number of clients, the number of consumers per client, and how each consumer is deployed and tested. For a small set of clients with a single owner each, the work can be scheduled as one change window. For a large estate, the time is spent on inventory, owner sign-off, staged rollout across environments, and verification that old secrets no longer work. Ask any partner to show a rotation plan with phases, a rollback path, and the owners who must approve each step. Request that the plan name the dependencies that set the schedule, such as release freezes and change approval boards.
What does the rotation work need from our internal team?
Your team needs to supply knowledge and access, not only approval. Engineers must identify which applications use each client and how they read configuration, and platform staff must grant rights to update secrets in the vault, Kubernetes, or CI systems where they live. A security or compliance owner should define the rotation interval and the evidence to keep. Someone must also own the rollback decision and monitor login errors during the cutover. Plan for these people to be available during the window, because the most common delays come from waiting on an owner who was not named at the start.
Can our team rotate Keycloak client secrets without outside help?
Yes, many teams can do it alone if they have Keycloak administration skills, a complete client inventory, and clear ownership of each application. The Keycloak admin console and Admin REST API both support changing a client's secret, and a scripted approach can make the work repeatable. The harder parts are usually outside Keycloak: finding hidden consumers, coordinating deployments, and proving that the change worked. Consider outside help if the estate is large, if you plan to move clients to signed JWT or mTLS, or if an auditor needs documented evidence. Confirm your team's capacity against the number of clients and environments before deciding.
What should we ask for in a quote for a client secret rotation project?
Ask for a written scope that lists the clients in scope, the authentication methods to be used after the change, and the environments covered. The quote should itemize inventory discovery, changes to Keycloak configuration, changes to each consuming system, testing, the rollback plan, and documentation. Ask who is responsible for each consumer change and what happens if an application owner is unavailable. Request a list of deliverables, such as a rotation runbook, an inventory of clients with their last rotation date, and evidence of verification. DeployOpen agrees fixed scope and timelines in writing before work starts, so ask any provider to state how changes to scope are priced and approved.
How do we find clients that still use long-lived secrets?
Start by listing every client with client authentication enabled in each realm, then record the authentication method and the date the secret was last changed. Keycloak stores this configuration, so an export or Admin REST API query can produce the inventory, but the change date may need to come from your own change records because it is not always visible in the console. Compare each client against your rotation policy and flag those that have never been rotated. Confirm with each owner whether the client is still in use before changing anything, because unused clients are a common source of stale credentials.
How DeployOpen scopes client authentication hardening
DeployOpen scopes client authentication hardening as a fixed-scope engagement, with the scope, deliverables and timeline agreed in writing before work starts. The work begins with a client inventory: every client in the realms in scope, its access type, whether it is confidential or public, which authenticator it uses today (client secret, signed JWT, mTLS or none), which flows it enables, and who owns it. Clients are then tiered by risk, based on the data and privileges reachable through their tokens, how exposed their redirect paths are, and whether they run in an environment you already control. Ask for this inventory format in any proposal, because it determines how much of the rest of the work is needed.
The next step is an authenticator migration plan, agreed with your application owners. It sets the order in which clients move from shared secrets to signed JWT or mTLS client authentication, the rotation policy for any secret that must remain for now, and the change window for each application. Implementation then happens in your own Keycloak, through your change process and your configuration management, so the resulting settings and the runbook belong to you. Verification covers sign-in and token exchange for each migrated client, confirmation that stale secrets are rejected, and a review of the logs that show which clients still authenticate with long-lived credentials.
The engagement ends with a handover of the rotation runbook, the client register and the verification evidence, and a walkthrough with the teams that will operate it. DeployOpen also offers retainers for ongoing secret rotation, Keycloak upgrades and periodic re-checks of new clients, which suit organizations whose application catalog keeps changing. Confirm during scoping which parts your own team will run after handover and which you want covered by a retainer, since that split drives the recurring cost.

