Repository navigation
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
oidc
Describe the bug
When a client uses Pushed Authorization Requests (RFC 9126), the realm setting PAR request URI lifespan (parRequestUriLifespan, default 60 s) does not only bound how long the request_uri reference may be redeemed at the authorization endpoint — it also silently bounds the maximum duration of the entire interactive authentication.
If the user needs longer than parRequestUriLifespan to complete login (MFA/OTP enrollment, e-mail verification, required actions such as UPDATE_PASSWORD or terms acceptance, identity-provider brokering, a slow user), the flow fails at authentication completion with:
KC-SERVICES0097: Invalid request: java.lang.RuntimeException: PAR not found, not issued or used multiple times.
The failure happens at authorization completion: the PAR payload is consumed before the authorization code is minted, so when the consume fails, no code is ever created and the browser is redirected back to the client with an error. The "Failure sequence" section below traces the exact ordering.
Raising parRequestUriLifespan to a value larger than the longest expected login makes the problem disappear, which confirms that the request-URI lifespan is being used as the login-duration limit.
This couples two independent concerns:
- the RFC 9126
request_urilifetime (a bound on redemption of the reference at the authorization endpoint), and - the maximum permitted interactive-authentication time, which Keycloak otherwise governs through the authentication session timeout.
Neither RFC 9126 nor RFC 6749 requires these to be the same value.
Version
26.7.1
Regression
- The issue is a regression
Expected behavior
Once a valid, non-expired request_uri has been presented and accepted at the authorization endpoint and interactive authentication has started, completing that authentication should be governed by the authentication session timeout, not by parRequestUriLifespan.
parRequestUriLifespan should limit only:
- how long the client may redeem the
request_uriat the authorization endpoint (initiation), and - one-time-use / replay protection of the reference.
A user taking, say, 3 minutes to complete OTP setup should be able to finish a PAR-initiated login even with the default 60 s parRequestUriLifespan, provided the authentication session itself has not timed out.
Actual behavior
The PAR payload is stored in the single-use store with a TTL equal to parRequestUriLifespan and is only consumed at authentication completion, which happens before the authorization code is minted (see "Failure sequence"). Because the store entry is evicted after parRequestUriLifespan seconds regardless of flow state, any interactive login that runs longer than parRequestUriLifespan finds the entry already gone at completion. The consume throws INTERNAL_ERROR, code minting is never reached, and the login ends in an error instead of a redirect carrying a code.
How to Reproduce?
- Enable the
parfeature. Leave the realm PAR request URI lifespan at its default (60 s). - Configure a client to use (or require) PAR.
POSTto the PAR endpoint and obtain arequest_uri(+expires_in: 60).- Redirect the browser to
/realms/{realm}/protocol/openid-connect/auth?client_id=...&request_uri=...and land on the login page. - Wait longer than 60 s on the login page before submitting — or, more realistically, trigger a step that legitimately takes longer than 60 s (OTP enrollment, e-mail verification, an
UPDATE_PASSWORD/terms required action, an IdP broker hop). - Complete authentication.
- Observe the failure: authentication is aborted and the server log shows
PAR not found, not issued or used multiple times.Nocodereaches the client'sredirect_uri. - Workaround: raise
parRequestUriLifespanabove the maximum expected login duration; the flow then completes.
Anything else?
ParEndpoint.request()reads the lifespan and puts the PAR payload into the single-use store with that value as the TTL:[ParEndpoint.java#L174](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/par/endpoints/ParEndpoint.java#L174)—int expiresIn = realm.getParPolicy().getRequestUriLifespan();[ParEndpoint.java#L186](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/par/endpoints/ParEndpoint.java#L186)—singleUseStore.put(CACHE_KEY_PREFIX + key, expiresIn, params);
- The store contract evicts the entry after that many seconds:
[SingleUseObjectProvider.java#L47](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/server-spi/src/main/java/org/keycloak/models/SingleUseObjectProvider.java#L47)—void put(String key, long lifespanSeconds, Map<String, String> notes);(lifespan is the minimum time the key is kept)
- Default lifespan is 60 s:
[ParConfig.java#L30](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/server-spi/src/main/java/org/keycloak/models/ParConfig.java#L30)—DEFAULT_PAR_REQUEST_URI_LIFESPAN = 60; // sec
- At the authorization endpoint the payload is read and an expiry check at presentation is performed (this part is fine and matches the RFC):
[AuthorizationEndpointRequestParserProcessor.java#L94](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/endpoints/request/AuthorizationEndpointRequestParserProcessor.java#L94)— instantiatesAuthzEndpointParParser[AuthzEndpointParParser.java#L60-L67](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/par/endpoints/request/AuthzEndpointParParser.java#L60-L67)— comparesnow - PAR_CREATED_TIMEagainstrequestUriLifespan, throwsPAR expired.if exceeded[AuthorizationEndpoint.java#L407](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/endpoints/AuthorizationEndpoint.java#L407)— stores therequest_urias an auth-session note for later
- Consumption is deliberately deferred to the point of authorization (correct, and required by a FAPI 2.0 conformance test), but it depends on the store entry still existing:
[AuthzEndpointParParser.java#L111-L119](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/par/endpoints/request/AuthzEndpointParParser.java#L111-L119)—removeRequestObject(...), with the comment referencingfapi2-security-profile-final-par-ensure-reused-request-uri-prior-to-auth-completion-succeeds[OIDCLoginProtocol.java#L587-L593](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java#L587-L593)—authenticationComplete()reads the note and callsremoveRequestObject(...); if it returnsnull, it throwsAuthenticationFlowException(..., AuthenticationFlowError.INTERNAL_ERROR)
The core problem: the single-use entry's TTL (ParEndpoint.java:186) equals parRequestUriLifespan, but the entry is not consumed until authenticationComplete(). So the entry's lifetime — intended to bound redemption of the reference — ends up bounding the whole interactive login. When login runs longer than parRequestUriLifespan, the entry is already evicted and completion fails.
Failure sequence — why no authorization code is issued
The decisive detail is the ordering inside [AuthenticationProcessor.authenticationComplete()](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java#L1250-L1256): the PAR consume runs before the authorization code is minted.
- User completes interactive authentication. Elapsed time since the PAR was pushed is now greater than
parRequestUriLifespan, so the single-use entrypar:<key>has already been evicted. AuthenticationProcessor.authenticationComplete()callsloginProtocol.authenticationComplete(authSession)—[AuthenticationProcessor.java#L1252](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java#L1252).- That calls
removeRequestObject(...), which returnsnull(entry gone) →OIDCLoginProtocol.authenticationComplete()throwsAuthenticationFlowException(INTERNAL_ERROR)—[OIDCLoginProtocol.java#L587-L593](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java#L587-L593). - Because step 3 throws, the very next line —
[AuthenticationProcessor.java#L1255](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java#L1255),AuthenticationManager.finishedRequiredActions(...)— is never reached. finishedRequiredActions()is the path that eventually calls[OIDCLoginProtocol.authenticated()](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java#L228)→[OAuth2CodeParser.persistCode(...)](https://github.com/keycloak/keycloak/blob/428187f25ed36f620380631d0b8d0be40e0ef6c4/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java#L280), i.e. where the authorizationcodeis actually created. Since step 4 is skipped,persistCode()never runs and nocodeexists.- The browser is redirected back to the client with an error rather than a
code, so login fails and the client obtains no tokens.
Why this is a spec-level over-restriction, not a requirement
- RFC 9126 §2.2 defines
expires_inas the lifetime of therequest_uriand expects it to be short (on the order of 5–600 s). It describes therequest_urias a single-use reference for the subsequent authorization request, and states explicitly that how the authorization server obtains the request data during the authorization process is at its discretion and out of scope. That leaves the server free to snapshot the data into the authentication session at first presentation. - RFC 9126 §4 requires one-time use of the
request_uriand that an expiredrequest_uribe rejected as invalid — i.e. at presentation at the authorization endpoint. It does not require the reference (or its backing data) to stay valid for the whole duration of interactive authentication, nor that authentication finish withinexpires_in. - RFC 9126 §7.3 recommends short-lived / one-time
request_urivalues to mitigate request-object replay. Forcing operators to inflateparRequestUriLifespan(e.g. to 30 min) purely to allow normal logins directly works against this recommendation — so "just raise the lifespan" trades away a security property to fix a usability bug.
Suggested direction
Decouple the interactive-authentication window from parRequestUriLifespan while preserving one-time-use and expiry-at-presentation:
Persist the PAR parameters into the authentication session when the request_uri is first accepted at the authorization endpoint, so completion no longer depends on the single-use entry
Related
- invalid_request when authenticating using PAR (Pushed Authorization Request) while Kerberos is enabled #36716 — "invalid_request when authenticating using PAR while Kerberos is enabled" reports the same
PAR not found, not issued or used multiple times.failure via a different trigger; it looks like another manifestation of consumption depending on the still-present single-use entry.
Metadata
Metadata
Assignees
Labels
Type
Fields
Projects
- StatusShow more project fieldsDone
Activity
mposolda commentedon Aug 31, 2026
Thanks for the report. This needs to be fixed as it is a regression recently introduced by #48072 (although not a critical regression, but needs to be fixed).
keycloak#51761 PAR request URI lifespan is used as a hard cap on inte…
6 remaining items
PAR request URI lifespan is used as a hard cap on interactive login d…
mposolda commentedon Sep 17, 2026
Backported in 26.7 branch: 74cd78d