Keycloak OIDC login for HashiCorp Vault

Sign in to HashiCorp Vault through Keycloak using Vault's JWT/OIDC auth method, with group-based roles and a tested break-glass method kept in reserve.

On this page

How Keycloak sign-in to Vault works and when to build it

Keycloak can be the sign-in source for self-managed HashiCorp Vault through Vault's JWT/OIDC auth method, so people use the same identities they already use for other applications. The integration registers Vault as a confidential openid-connect client in Keycloak with the standard flow enabled, then maps Keycloak group membership to Vault roles and, through those roles, to Vault policies. Build it when your team runs its own Vault cluster, already operates Keycloak as the workforce identity provider, and wants access to secrets to follow joiner, mover and leaver changes made in one place.

Before you build, decide who will administer the Keycloak client and who owns the group-to-policy mapping, because those two settings decide what every signed-in user can read and write. Confirm which Vault edition and license terms apply to your deployment. The supplied facts state that Vault is available as Community Edition binaries or source, as licensed Vault Enterprise, and as HCP Vault Dedicated, and that HashiCorp moved future releases to the Business Source License 1.1 with IBM named as licensor in the Vault LICENSE file. Read the license text with your legal team before you rely on it for a commercial platform, and confirm which Enterprise features you need, since several require a license applied to the cluster.

The integration does not replace Vault's root token or unseal keys, and it should not be the only way in. Plan a break-glass auth method that stays available when Keycloak, its network path or its certificates fail, and test it before go-live. Vault's own Keycloak instructions cover the client and callback setup, so this section is the point to settle ownership, licensing and recovery before the build starts.

What you need before configuring Vault and Keycloak

Four things have to be in place before any client or mapping is created: a Keycloak deployment, a Vault server, a network path between them and users, and an admin role able to change Keycloak clients and groups. Each card below names one of these pieces and the check to make before you start.

A Keycloak release line you can keep current

Start from a current Keycloak release and confirm your team has a plan to track the minor releases, which the project now ships four times a year. The current release is 26.8.1, so check that the version you deploy is supported by your patching process. Ask whether your team will apply upgrades through the Operator in manual approval mode, which the Keycloak Operator documentation strongly recommends to avoid unintended upgrades.

Keycloak upgrading guide

Keycloak served over TLS on a production database

Keycloak should run in production mode with TLS on all communication, behind a reverse proxy. Confirm the database is one of the supported production options rather than the development file database, because the Vault login depends on Keycloak being available for every sign-in. Check the hostname that clients will use for the issuer URL, since Vault validates it during discovery.

Keycloak production guide

A self-managed Vault server with its own TLS

Vault must be reachable over HTTPS with a certificate your users and browsers trust, because the OIDC callback returns to the Vault UI and CLI. Confirm who holds the unseal keys or auto-unseal mechanism and how an operator unseals Vault after a restart. Note that Vault login failures during an outage of Keycloak do not replace the need for a working unseal process.

Vault edition and license status

Confirm with HashiCorp or IBM, and in your own procurement records, whether your team runs Community Edition binaries or licensed Vault Enterprise. Some features you may expect, such as performance replication, namespaces or control groups, are Enterprise features that need a license applied to the cluster. Check your Vault version against the release notes before you rely on any OIDC behavior.

Vault Enterprise docs

Network paths for users, Keycloak and Vault

Three paths must work: users reach both the Keycloak login page and the Vault UI in a browser, the Vault server reaches Keycloak's discovery and token endpoints, and CLI users reach Vault's callback port on their workstation. Map each path through your firewalls and proxies before you start. Name the hostnames you will use now, because changing them later means updating the Keycloak redirect URIs and Vault configuration.

A Keycloak admin role for client and group setup

The person configuring this needs a Keycloak role that can create clients, read client credentials, manage client scopes and mappers, and create groups in the target realm. Keep that role separate from the realm break-glass admin account and confirm who approves changes. Record which admin accounts exist, because a Vault policy mapping mistake is easier to recover from when the Keycloak admin path is known in advance.

How to configure the Keycloak client and Vault OIDC auth method

This sequence sets up Keycloak as the OpenID Connect provider for Vault, so operators sign in with their corporate identity and receive Vault policies from Keycloak group membership. The result is a tested UI and CLI login path that works before any break-glass method is retired.

  1. Create a dedicated realm and confidential client

    An identity administrator creates a realm for Vault access, separate from workforce applications where possible, then adds an openid-connect client in that realm. Set the client to confidential access type with the standard flow enabled, following HashiCorp's Keycloak provider instructions. Done means the client appears in the Keycloak admin console with a Credentials tab showing a client secret, and the realm's OpenID discovery document loads in a browser.

  2. Register the Vault UI and CLI callback URIs

    In the client's valid redirect URIs, add the Vault UI callback path /ui/vault/auth/oidc/oidc/callback and the CLI path /oidc/oidc/callback, using the exact hostname that operators reach Vault on. Keep these entries limited to your Vault addresses rather than wildcards. Done means both URIs are saved on the client and the redirect URI list matches the Vault addresses your team uses.

  3. Copy the client ID and secret into Vault

    Copy the client ID from the client's settings and the client secret from the Credentials tab. Store the secret in a location your operators control, not in a shared document, because it will be written into Vault's auth configuration. Done means you hold both values and the secret has been recorded in your secret handling process, with the Keycloak admin who issued it named in your change record.

  4. Enable the JWT/OIDC auth method in Vault

    A Vault administrator enables the JWT auth method at the OIDC path used by the callback, for example with vault auth enable oidc, then writes the configuration. Set the OIDC discovery URL to the Keycloak realm's issuer, and set the client ID, client secret and bound redirect URIs from the earlier steps. Done means vault read on the auth configuration shows the discovery URL and both redirect URIs, and the path matches the callback URIs registered in Keycloak.

  5. Create roles that map Keycloak groups to policies

    Define one Vault role per access level, with a user_claim, groups_claim and allowed_redirect_uris set, and bind each role to Vault policies. Use the Keycloak groups claim as the basis for bound_claims or the group-to-policy mapping in Vault identity groups, and confirm the groups claim appears in the ID token before relying on it. Done means each role lists the expected policies and a test user in the mapped Keycloak group receives only those policies.

  6. Test UI and CLI logins with a non-admin user

    Sign in through the Vault UI and then through the CLI with vault login -method=oidc, using a user from the mapped group. Check the token's attached policies with vault token lookup and confirm access to one secret path inside and one outside the policy. Done means both login paths return a token with the expected policies and the out-of-scope path is denied, and the results are recorded for the change.

  7. Retain a break-glass auth method and document recovery

    Keep a separate, tested break-glass method, such as a root token procedure or a locally managed userpass or approle account held by a named custodian group, before disabling any previous login path. Document where the unseal material and the emergency credential sit, and test that the break-glass login works while Keycloak is unreachable. Done means the break-glass login succeeds in a test window and the runbook names the custodians and the steps.

How a Vault login travels through Keycloak

The login starts in the user's browser or the Vault CLI, which calls Vault's OIDC auth endpoint. Vault redirects the user to Keycloak's authorization endpoint, and Keycloak returns the user to one of the two callback URIs registered on the confidential client: the UI callback or the CLI path. Vault then exchanges the code at Keycloak's token endpoint and checks the groups claim against the bound claims of a Vault role before issuing a Vault token. Check that both callback URIs match exactly and that the groups claim is present in the ID token.

Sequence of a Vault OIDC login, with Keycloak as the identity provider and Vault role matching as the final gate.

Configuring UI and CLI logins differently

Operators who open the Vault web UI and choose OIDC sign-in are redirected to Keycloak, then back to Vault's UI callback path. Vault's Keycloak instructions name that path as /ui/vault/auth/oidc/oidc/callback, and the redirect URI must match it exactly, including scheme, host and port, because Keycloak rejects any other value. The UI path is the one most people test first, so it is usually the first one that breaks when the Vault address changes.

  • Exact redirect URI: register the full UI callback URL built from your Vault address, not a wildcard or the bare hostname.
  • Vault address in the browser: the address users type must match the address in the redirect URI. A load balancer name and an internal name can produce two different URLs.
  • Confidential client: the UI flow uses the client ID and secret from the Keycloak Credentials tab, so the client must stay confidential.
  • Role binding: the role that Vault uses to decide the policy is chosen at sign-in, so the UI path needs the same role definitions as the CLI path.
  • Test with a non-admin user: confirm the policy a normal engineer receives, not only the break-glass administrator.

Before you go live, sign in as a test user from a clean browser session and confirm that Vault lists only the policies you intended.

Mapping Keycloak groups and claims to Vault roles and policies

This table lists each setting that connects a Keycloak group to a Vault policy, from the claim that carries group membership to the Vault role, token lifetime and entity alias. Read it top to bottom when you build the mapping, and check each value against the exact claim your Keycloak client emits, because a single character mismatch in a group name stops the mapping from matching.

SettingWhere it livesWhat to set and confirm
Group claimKeycloak client mapperAdd a groups mapper to the Vault client so the ID token carries group membership. Confirm the claim name and whether full group paths or short names are emitted.
Bound claimsVault JWT/OIDC roleBind the role to the group claim value, for example a group named vault-admins. The value must match the emitted claim exactly, including case and any path prefix.
Allowed redirect URIsKeycloak client and Vault roleRegister the UI callback and the CLI callback paths in Keycloak. Set the same URIs in the Vault role so the login flow completes for both the browser and the command line.
Policies per groupVault role token_policiesAssign one or more Vault policies to each role. Keep each group mapped to the least privileged policy set that its team needs, and review the mapping when group membership changes.
Token TTL settingsVault role token_ttl and token_max_ttlSet how long a Vault token lasts and the maximum it can be renewed. Confirm the values against your session policy, since shorter lifetimes force more frequent sign-ins.
User identity fieldsVault role user_claim and entity aliasChoose the claim that names the user, such as the subject or preferred username. This value becomes the entity alias, so changing it later creates a new identity in Vault.
Break-glass methodSeparate Vault auth methodKeep a non-OIDC method, such as a userpass or token account held by named custodians, that works when Keycloak is unavailable. Confirm that it is tested and its access is logged.

Securing the Keycloak to Vault trust relationship

Signing in to Vault through Keycloak makes the identity provider a gatekeeper for secrets. The controls below cover the client credentials, transport, redirect paths, token lifetimes, administrative separation and logging that keep that trust narrow. Check each one in your own environment before the integration goes live.

Confidential client secret handling

The Vault client in Keycloak uses the confidential access type, so the client secret is copied from the Credentials tab into Vault's OIDC configuration. Store that secret in a controlled location, limit who can view it in Keycloak, and record who holds it. Plan a rotation procedure that updates Keycloak and Vault in the same change window, because a mismatch blocks every UI and CLI sign-in.

Vault Keycloak docs

TLS on both ends

Vault redirects the browser to Keycloak and Keycloak returns the user to Vault, so both endpoints should serve HTTPS with certificates your clients trust. Keycloak's production guide calls for TLS on all communication behind a reverse proxy. Confirm that the issuer URL Vault uses matches the public hostname in Keycloak's configuration, since mismatches surface as discovery or token validation errors.

Keycloak production guide

Exact redirect URIs only

Register only the Vault UI callback at /ui/vault/auth/oidc/oidc/callback and the CLI callback at /oidc/oidc/callback, with the exact host of each Vault address. Avoid wildcard redirect patterns, which widen the set of URLs that can receive authorization codes. Review the list whenever a Vault hostname or load balancer changes.

Least-privilege policies per group

Keep Keycloak groups mapped to narrow Vault roles, each bound to a policy that grants only the paths that group needs. Do not map a broad administrative group to a default policy. Review group membership on a schedule, and test each role with a non-administrative account before rollout. Illustrative example: a developers group receives read access to one application's KV path only.

Short token lifetimes

Set Keycloak access and session lifetimes to values your security policy allows, and set Vault token TTLs and maximum TTLs so that a revoked or removed user loses access within a bounded window. Confirm how Vault handles renewal for OIDC-issued tokens in your version, and test a removal from a Keycloak group end to end.

Keycloak admin separation from Vault admin

Keep the people who administer the Keycloak realm and clients separate from those who hold Vault root or policy-write rights where your control model requires it. A Keycloak administrator who can change a group membership or client secret can change what Vault grants. Document both administrative paths and review who can reach each one.

Audit logging on both systems

Enable Vault's audit devices so each login, token issuance and secret access is recorded, and keep Keycloak's admin and login event logs. Correlate Keycloak sign-in events with Vault entity and token records by user identity. Confirm retention periods and log forwarding with your security team, since neither product's default settings may meet your requirements.

Why Vault needs a tested break-glass login

If Keycloak fails, every OIDC user loses access to Vault at once. The failure can come from the Keycloak server itself, from the TLS certificate on the public issuer hostname, or from DNS records that resolve the issuer URL that Vault uses for discovery. Each of these stops sign-in, and Vault's OIDC login has no fallback unless you configure one. Before you enable the Keycloak method as the only interactive path, decide which separately governed method will let a small set of named operators reach Vault during an identity outage, and write that decision down.

Choose the break-glass method deliberately. A root token generated under controlled conditions, a userpass or AppRole method limited to a few administrators, or another auth method your team already governs can each serve the purpose, but each has different custody and rotation needs. Assign named custodians who can retrieve the credentials, store them in a sealed location with dual control and access logging, and record who holds each part. Confirm with your own security team how the storage system, the custodian roster and the emergency procedure fit your control framework, because no single product setting handles that for you.

Test the path on a schedule, not only when an outage occurs. A scheduled test should sign in through the break-glass method, confirm the expected policies apply, rotate or revoke the test credential as your procedure requires, and log the result. Because a local-only path bypasses the usual identity controls, document it as an exception, alert on every use through Vault's audit devices, and review each use after the fact. Vault's documentation on Keycloak OIDC provider setup covers the OIDC side, but the break-glass design is yours to verify in your environment.

Common Vault and Keycloak login failures and their fixes

This table pairs each common failure in Keycloak OIDC login for Vault with its likely cause and the fix to try first. Read it in order when a sign-in fails, because several symptoms look identical from the browser but have different causes in Keycloak, Vault, or the network path between them.

FailureLikely causeFix
Redirect URI mismatch at KeycloakThe client's valid redirect URIs do not include the exact Vault UI callback (/ui/vault/auth/oidc/oidc/callback) or the CLI callback (/oidc/oidc/callback) for the Vault address in use, often because of a trailing slash, http versus https, or a different hostname.Add both callback paths under the Vault client's valid redirect URIs using the exact scheme, host, and port Vault advertises, then retry. Confirm the Vault address in the auth method config matches the browser address.
CLI login fails while UI login worksOnly the UI callback was registered, so the CLI's localhost callback request is rejected by Keycloak.Register the /oidc/oidc/callback path as well, and confirm the CLI host is allowed to receive the redirect from the workstation running vault login.
Invalid client or unauthorized client errorThe client secret in Vault does not match the secret on Keycloak's Credentials tab, usually after the secret was regenerated or copied with stray whitespace.Copy the current secret from the Credentials tab again and update the Vault OIDC config with the new value. Confirm the client is confidential and the standard flow is enabled.
Discovery or issuer URL failsThe oidc_discovery_url points at the wrong realm, uses a hostname Vault cannot resolve, or the issuer in the discovery document differs from the configured value, which Vault rejects.Open the realm's OpenID configuration URL from the Vault host and confirm the issuer field matches the oidc_discovery_url value exactly. Fix DNS or the reverse proxy path, not the Vault setting.
TLS certificate trust errorVault cannot verify the certificate of Keycloak because the internal certificate authority is not in the trust store of the Vault nodes.Install the internal CA on every Vault node, or supply the CA through the Vault configuration, then restart or reload and test discovery from each node, not only the first.
No role matched on loginThe groups claim is missing from the ID or access token, or it is named differently from the claim the Vault role's group or bound claim expects.Decode a test token from the Keycloak user, check the claim name and value format, and add or rename the groups mapper so the claim matches the Vault role configuration.
Groups claim present but emptyThe Keycloak user is not a member of the group the role expects, or group paths include a leading slash the Vault role does not match.Confirm the user's group membership in the realm, and align the group claim format and the bound claim value with the exact string Keycloak emits.
Authenticates but receives no policiesThe role maps to no token policies, or the policies named on the role do not exist in Vault, so the token carries only the default policy.Run vault read on the role and vault token lookup on the new token, then create the missing policy or correct the policy name on the role.
Token rejected as not yet valid or expiredClock skew between Keycloak, Vault nodes, and the user's workstation makes iat or nbf claims fall outside the allowed window.Enable time synchronization on all three sides with NTP or the platform's time service, then retry. Do not widen token validation to hide the drift.

Questions buyers ask before configuring Keycloak with Vault

What drives the cost of configuring Keycloak as the OIDC login for Vault?

The cost depends on how many Keycloak realms, clients and group structures are involved, how many Vault auth paths and policies must be mapped, and whether the Keycloak and Vault environments already exist. Two parties are paid in a typical engagement: the internal team's time and any partner's fixed-scope fee, and both are one-time for the initial configuration. Recurring costs are upgrades to Keycloak and Vault, periodic review of group-to-policy mappings, and the Keycloak and Vault infrastructure itself. Ask any quote to itemize the Keycloak client setup, the Vault JWT/OIDC role design, the policy mapping, the break-glass test and the handover documentation, and to state which items are one-time and which are recurring.

How long does a Keycloak to Vault OIDC integration take?

Duration depends on the number of groups that need Vault policies, whether the Keycloak realm already emits a groups claim, and how many environments (development, test, production) must be configured and approved. A single-environment setup with a small group model is usually shorter than a multi-environment rollout with change control. No fixed duration is supplied for this work, so ask for a timeline tied to a written scope and confirm which approvals, network reachability checks and test windows are included in it.

What does the client's team need to provide before the work starts?

The client should provide administrative access to the Keycloak realm and to Vault, a list of the groups that should map to Vault policies, the Vault UI and CLI addresses that users will use, and the TLS certificate chain that both systems trust. Teams also need to name who approves the Keycloak client secret handling and who owns the break-glass credentials. Confirm in the quote whether the work includes creating these Keycloak groups or whether they already exist in the directory Keycloak federates.

Can an internal team configure Keycloak with Vault without a partner?

Yes, an internal team with Keycloak and Vault administration skills can complete this integration on its own. The work is mostly configuration: a confidential Keycloak client with the standard flow enabled, the Vault UI and CLI callback URIs, a JWT/OIDC auth method with roles bound to group claims, and policies that match least privilege. The harder part is testing the mapping across real users and keeping the break-glass path tested. Teams that lack recent Vault policy experience often bring in outside help for the policy design and the break-glass exercise.

What changes when Vault is Enterprise instead of Community Edition?

The OIDC configuration itself is largely the same, because the Keycloak provider documentation describes the JWT/OIDC auth method without requiring an Enterprise license. The differences are in the surrounding platform. Vault Enterprise documentation lists features such as namespaces, performance and disaster recovery replication, control groups, Sentinel policy as code, MFA and FIPS compliance as features that need a license applied to the cluster. If your access model depends on namespaces or Sentinel, plan that design separately and confirm licensing with HashiCorp or your vendor before the work starts. HCP Vault Dedicated runs the same binary as self-managed Vault Enterprise, but its operating model differs, so confirm which model you will run.

How is the break-glass login test run?

Run the test on a non-production Vault first and then repeat it on production during a planned window. Disable the Keycloak OIDC login path in a controlled way or simulate an unavailable identity provider, then confirm that the break-glass auth method, such as a token or other method kept in your documented recovery procedure, can still sign in with the policies needed for recovery. Record who can use the break-glass method, where its credentials are stored, and how access is revoked after the exercise. Repeat the test after any change to Keycloak clients, Vault auth methods or policies, and on a schedule your operations team sets.

Which Keycloak and Vault versions should the integration target?

Target the current supported versions at the time of the build, and confirm them before configuration. At the time of writing, the current Keycloak release is 26.8.1, published October 13, 2026, and the current HashiCorp Vault release is 2.2.0, released October 15, 2026. Keycloak documents that minor releases can carry opt-in breaking changes, and its 26.8 upgrade notes change several behaviors, including mandatory backchannel logout token signature validation. Check the upgrade notes for both products before you choose a version, and ask the quote to include a version check.

How DeployOpen scopes and delivers this integration

DeployOpen delivers this integration as a fixed-scope engagement, with the scope, deliverables and timeline agreed in writing before any configuration starts. For this work, the written scope should name the Keycloak realm and client, the Vault cluster and auth mount path, the groups-to-policies mapping and the break-glass method, so that both sides know exactly what is being changed. The quote follows from that document, and it should list which items are one-time work and which recur.

Configuration happens inside your own Keycloak and Vault, under your change control. That means the confidential client and its credentials, the UI and CLI callback URIs, the groups claim mapper and the Vault JWT/OIDC roles are set up in environments you own and can review. Testing covers the browser UI login, the CLI login, the policy each group actually receives and the break-glass path, which should be exercised by someone who is not the person who built it. Confirm with us whether the test plan also covers Vault Enterprise features if your cluster runs them.

Handover includes written documentation of the client settings, role definitions, group mappings and recovery steps, so your platform team can operate the integration after the engagement ends. Ongoing work is available as optional retainers for Keycloak and Vault upgrades and for continuous testing of the login paths, which we recommend you price separately from the initial build. DeployOpen does not issue audit reports or certifications, so any evidence you need for an assessment should be confirmed with your auditor before the scope is signed.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.