Keycloak JWT authorization grant (RFC 7523)

How to let a confidential client exchange a signed JWT from a trusted issuer for a Keycloak access token, with the identity provider, client and claim settings and the limits that shape the design.

On this page

When a Keycloak JWT authorization grant replaces a client secret

A backend workload that already holds a signed identity token from another system can trade that token for a Keycloak access token without storing a shared client secret. The JWT authorization grant does this for confidential clients: the client posts a signed JWT with the grant type urn:ietf:params:oauth:grant-type:jwt-bearer, and Keycloak validates it against an issuer you have configured. The mechanism follows RFC 7521 and RFC 7523, and in Keycloak it is the jwt-authorization-grant:v1 feature, which is supported and enabled by default according to the Keycloak features guide. Check the feature state in your own build before you rely on it, since a deployment can disable features explicitly.

The grant fits a service-to-service case where the trust decision already lives with another system, such as a workload identity platform, a cloud provider's token service or an internal CI issuer that signs short-lived assertions. Keycloak then accepts the assertion as proof of the client's identity, so you avoid distributing and rotating a client secret to that workload. It is not a replacement for interactive sign-in, so users logging into a browser or mobile app still need the authorization code flow. It also does not suit public clients, because the grant is available only to confidential clients, and it is not a general token exchange for swapping one Keycloak token for another. For that pattern, see the sibling topic on token exchange.

Before you commit, confirm three things with your security team: which issuers you will trust, how the sub claim maps to a user linked to the identity provider, and how the workload's signing keys are rotated and revoked. The grant issues no refresh tokens, always creates a transient session and is not covered by brute force protection, so a stolen assertion is the main attack path to plan around. Ask the issuer owner whether assertions can be made short-lived and single-use, and treat the workload's private signing key as the new credential that replaces the secret.

How the assertion flows from the external issuer to Keycloak

The flow starts with the external issuer, which signs a JWT for the confidential client. The client posts that assertion with the JWT bearer grant type to the Keycloak token endpoint. Keycloak checks the assertion against the configured identity provider: iss, a single-valued aud, exp, and jti unless reuse is allowed. It then matches sub to a user linked to that provider. If every check passes, Keycloak returns an access token, and no refresh token. Check each hand-off, because a mismatch at any step fails the grant.

Assertion exchange from the external issuer through Keycloak, ending in an access token without a refresh token.

Identity provider and client options and when each fits

This table compares the two identity provider types that can accept a signed JWT assertion, the client authentication choices for the confidential client, and the assertion lifetime and jti reuse settings. Read each row against the trust relationship you have with the issuer. The main takeaway is that the provider type follows how the issuer publishes its keys, and the reuse setting should stay off unless the issuer cannot give each assertion a unique jti.

OptionHow it worksWhen it fits
OpenID Connect identity providerKeycloak discovers the issuer's keys and metadata from its OpenID Connect configuration, then validates assertions against themThe issuer publishes standard OIDC discovery and a JWKS endpoint that Keycloak can reach
Dedicated JWT Authorization Grant identity providerKeycloak trusts the issuer through settings you enter for that issuer, without relying on full OIDC discoveryThe issuer is a workload or service platform that signs JWTs but does not offer a complete OIDC setup
Confidential client with signed JWT authenticationThe client proves its identity with a key pair, and the grant is available only to confidential clientsA backend service or job that can hold a private key and call the token endpoint directly
Public clientNot eligible for this grant, because the grant is available only to confidential clientsNot a fit. Use another grant such as authorization code with PKCE for browser or mobile clients
Default maximum assertion expiration of 5 minutesAssertions with an exp claim beyond the configured maximum are rejectedKeep the default when the issuer mints short-lived tokens per request. Confirm the issuer's clock and token lifetime before you raise it
jti reuse not allowed (default)Each assertion needs a unique jti, which Keycloak uses to block replayRecommended for most setups, since a replayed assertion is then rejected
jti reuse allowedKeycloak accepts the same assertion more than once within its validity windowOnly when the issuer cannot generate unique jti values. Accept the replay risk and shorten the expiration to compensate

Configuring the identity provider, client and claims

This sequence takes a Keycloak realm from the feature flag to a working JWT authorization grant, so a confidential client can exchange a signed assertion from a trusted issuer for a Keycloak access token. Each step ends with a check you can run before moving on.

  1. Confirm the JWT authorization grant feature is enabled

    Check that the jwt-authorization-grant:v1 feature is active on the running server, since it is supported and enabled by default. Your Keycloak administrator confirms this in the server configuration and by reviewing the feature list the server reports at startup. Feature state is set by your deployment, so if your team has disabled features for hardening, re-enable this one explicitly. Done means the feature appears as enabled in the server output, and a token request with a JWT bearer grant type no longer fails for feature reasons.

  2. Register the trusted issuer and its signing keys

    Create an identity provider for the external issuer, using the OpenID Connect or dedicated JWT Authorization Grant type, and load the issuer's keys or its key endpoint. Your security team should confirm with the issuer owner which signing algorithms and key IDs they use, and record who owns key rotation on that side. Done means the identity provider saves without error and Keycloak can list the issuer's signing keys, which you can check by sending a test assertion signed with a key that is not registered and confirming it is rejected.

  3. Create the confidential client and enable the grant

    Create a client with client authentication turned on, since the grant is available only to confidential clients, and enable the JWT authorization grant for it. Limit the client's scopes to what the calling service needs, and store its client secret or other credential in your secrets manager. Done means the client shows as confidential, the grant is listed as enabled for it, and a public client attempt to use the grant is refused.

  4. Map the assertion sub to a linked Keycloak user

    Link the external sub value from the assertion to a Keycloak user through the identity provider's link settings. Keycloak requires that sub match a user already linked to the identity provider, so decide with the data owner whether accounts are linked in advance or by an administrative process. Done means a test assertion with a known sub issues a token for the matching user, and an assertion with an unlinked sub is rejected.

  5. Set required claims and the expiration limit

    Confirm the assertion must carry iss, a single-valued aud, exp and jti unless reuse is allowed, and review the maximum assertion expiration, which defaults to 5 minutes. Keep jti required so replay protection stays in place, and set the audience to the Keycloak realm issuer your team documents. Done means a test assertion missing jti or carrying a multi-valued aud is rejected with an error that your team can find in the event log.

  6. Test with a signed assertion and check the expected results

    Sign a test assertion with a registered issuer key, using a short-lived exp and a unique jti, and request a token from the realm token endpoint with the JWT bearer grant type. Then run the negative cases: an expired assertion, a reused jti, a wrong aud and an unknown sub should each be rejected. Done means the valid assertion returns an access token with no refresh token, and each negative case fails as expected and appears in the logs. Record these results so the setup can be repeated after upgrades.

Replay protection and trust decisions for signed assertions

A signed assertion is only as safe as the decisions around it: who may issue it, who it is addressed to, how long it stays valid and whether it can be used twice. The cards below cover the settings and checks that connect those decisions in a Keycloak JWT authorization grant deployment.

Require jti to block replay

The jti claim is what stops one assertion from being presented twice. Keycloak requires jti unless reuse is explicitly allowed, and allowing reuse means a copied assertion can mint new access tokens for as long as it remains valid. Confirm that the identity provider setting for assertion reuse is off in every environment, and test that a second submission of the same assertion is rejected.

Default maximum expiry
5 minutes
JWT grant guide

Keep assertion lifetime short

The exp claim should sit well inside the default maximum of 5 minutes, so a captured assertion has little time to be abused even if replay checks fail. Ask the issuing system to set short lifetimes and confirm the maximum expiration configured in Keycloak matches the lifetime your issuer actually uses. Clock skew between the issuer and Keycloak should be measured before you tighten the window.

Pin the issuer and key set

Keycloak should trust one configured issuer and its published keys, not whatever key an incoming token claims to use. Register the issuer as an OpenID Connect or JWT Authorization Grant identity provider, restrict which signing keys it accepts, and document the process for rotating those keys. Review who can change the identity provider settings, because changing the trusted issuer changes who can obtain tokens.

Restrict aud to the Keycloak realm

The aud claim must name the Keycloak realm as its single audience, which stops an assertion issued for another service from being redeemed here. Keycloak expects a single-valued aud, so multi-audience tokens from the issuer will fail until the issuer is configured to emit one value. Check this with a test assertion addressed to a different audience and confirm it is refused.

Map sub to linked users only

The sub claim must match a user already linked to the identity provider, so an assertion cannot create or select an arbitrary account. Decide who links accounts and how, whether by administrator action or a controlled process, and keep that step outside the issuer's control. Verify that an assertion naming an unlinked subject is rejected rather than silently provisioned.

Monitor rejected assertions

Rejected assertions are the earliest signal of misconfiguration or abuse, so collect them as an operational signal rather than discarding them. Turn on the Keycloak logs for the grant and enable the metrics endpoint on the management interface with --metrics-enabled=true so that failure counts can be charted and alerted on. Also remember that the grant is outside brute force protection, so rate limits and alerts on failures need to come from your own monitoring.

Keycloak metrics guide

Questions teams ask before building a JWT grant in Keycloak

How much effort does a Keycloak JWT grant build take, and what drives it?

Effort depends mostly on the number of issuers, how much claim mapping the identity provider needs, and how the signing keys are managed. Each trusted issuer needs its own identity provider configuration, its own trust settings and its own test cases, so a single issuer with a simple sub match is far smaller work than several issuers with different key sources and claim rules. Key management adds work when keys rotate often or must be fetched from a JWKS endpoint. Ask any partner to break the quote down by issuer, claim mapping, key handling and verification testing, so you can see which items change if the issuer count grows.

Can our own team build a JWT authorization grant without a partner?

Yes, a team with Keycloak administration experience and access to the issuer's signing setup can build the grant alone, because the configuration is confined to an identity provider, a confidential client and a set of realm settings. The harder parts are usually outside Keycloak: confirming that the issuer signs assertions correctly, that aud and exp values are set as Keycloak expects, and that replay protection holds under real traffic. If your team has not tested token validation before, a short external review of the design and test plan can reduce rework. Whether to bring in a partner depends on your internal capacity and on how many issuers you expect to onboard.

What do we need from the issuer owner and the Keycloak admins?

The issuer owner must provide the issuer identifier, the audience value they will place in assertions, the signing algorithm and key or key endpoint, and the claim that carries the subject. They must also confirm they can set a short expiry and a unique jti on every assertion. Keycloak administrators need to create the identity provider and the confidential client, link each expected subject to a user, and decide whether reuse of assertions is allowed. Agree on who owns key rotation before go-live, because a rotation the issuer makes without telling Keycloak will cause sign-in failures.

How do we handle the loss of brute force protection on this grant?

The JWT grant is not covered by Keycloak's brute force protection, so repeated invalid assertions will not trigger the lockout that protects password logins. Compensate at the issuer and the network layer: restrict which clients can call the token endpoint, rate limit requests where your gateway or proxy allows it, and keep the issuer's signing keys tightly controlled. Monitor failed grant attempts through Keycloak's logs and metrics so unusual patterns are visible. Record this gap in your risk register and confirm with your security team that the compensating controls meet your policy before you rely on the grant for production access.

Do we need refresh tokens with a JWT authorization grant?

No refresh token is issued by this grant, so the client must request a new assertion from the issuer whenever it needs a new access token. This works well when the issuer can mint short-lived assertions on demand, because the client's trust chain stays with the issuer. If your application expects long sessions with silent renewal, design for that before building: either the issuer must produce fresh assertions on a schedule, or the workload must accept re-authentication. Confirm the token lifetime requirements of each consuming service early, since they determine how often assertions must be created.

How do we confirm the JWT grant feature is enabled in our Keycloak version?

The feature is named jwt-authorization-grant:v1, and Keycloak's feature guide lists it as supported and enabled by default. Confirm this against the exact version you run by checking the features documentation for that release, then verify on your own server, for example by listing the enabled features at startup or by testing a grant against a non-production realm. If an administrator has disabled it through configuration, the grant will fail even though the client and identity provider look correct. Include this check in your pre-production test plan and repeat it after every upgrade.

Which replay protection settings should we require from the issuer?

Require every assertion to carry iss, a single-valued aud, exp and a unique jti, unless your design explicitly allows reuse. Keycloak's default maximum assertion lifetime is 5 minutes, so the issuer should mint assertions with a short expiry well inside that window. The sub value must match a user linked to the identity provider, so unlinked subjects will be rejected. Test replay by sending the same assertion twice and confirming the second request fails. Keep a written record of these settings so future changes to the issuer are reviewed against them.

What to confirm with your issuer and Keycloak version

Confirm the items on the issuer side before any Keycloak configuration is written. Ask the issuer team which signing algorithms they use for the assertions, how keys are published and rotated, and how long a retired key remains valid. Keycloak must be able to fetch or be given the matching public keys, so a rotation the issuer performs without notice will reject every assertion until the identity provider configuration is updated. Agree on the clock skew tolerance too: the assertion's exp and iat values are only as reliable as the clocks that set them, and the default maximum assertion lifetime of 5 minutes leaves little room for drift. Write down who is the owner of the sub mapping, because the sub claim must match a user already linked to the identity provider, and a mismatch is a failure that the issuer team cannot see from their side.

On the Keycloak side, confirm the target release and the state of the jwt-authorization-grant:v1 feature in that release. The feature is enabled by default according to the Keycloak features guide, but your platform team should still verify the effective setting in the environment they run, including any build-time options or configuration that disable it. Record the Keycloak version you intend to deploy, then check the JWT Authorization Grant guide for that version, because identity provider options, required claims and assertion handling are the behaviors most likely to change between releases. Use the Keycloak JWT Authorization Grant guide as the reference for current behavior, and capture the results of a test assertion in a non-production realm before the issuer goes live.

How DeployOpen scopes and delivers a JWT grant integration

DeployOpen plans, builds, tests and documents Keycloak JWT authorization grant (RFC 7523) inside your own infrastructure, as part of a self-hosted Keycloak deployment. Work starts with a written scope that names the trusted issuers, the confidential clients and the claim rules, so your security and identity teams can review the design before anything is configured.

How we scope

  • Inventory every workload that will present a signed JWT and confirm it is a confidential client.
  • Agree the trusted issuers, their signing keys and the required iss, aud, exp and sub values in writing.
  • Record the replay protection, assertion lifetime and session handling choices before build starts.

How we build

  • Configure the OpenID Connect or dedicated JWT Authorization Grant identity provider for each agreed issuer.
  • Link each sub claim to the matching Keycloak user and set the identity provider mappers accordingly.
  • Confirm the jwt-authorization-grant:v1 feature is enabled in your Keycloak release before testing.

How we hand over

  • Deliver the realm, identity provider and client configuration as reviewable records with change history.
  • Provide test evidence for accepted assertions, rejected reused jti values, expired and wrongly audienced tokens.
  • Document the limits your teams must plan around, including no refresh tokens and no brute force protection.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after handover.
  • Retest the grant after Keycloak upgrades, issuer key rotation or changes to client policies.
  • Review issuer and client changes against the written scope before they reach production.

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.