Skip to content

[backport camel-4.18.x] CAMEL-23504: camel-keycloak - include IS_ACTIVE check in parseAndVerifyAccessToken#23204

Merged
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/23197-to-camel-4.18.x
May 14, 2026
Merged

[backport camel-4.18.x] CAMEL-23504: camel-keycloak - include IS_ACTIVE check in parseAndVerifyAccessToken#23204
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/23197-to-camel-4.18.x

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 14, 2026

Backport of #23197

Cherry-pick of #23197 onto camel-4.18.x.

Original PR: #23197CAMEL-23504: camel-keycloak - include IS_ACTIVE check in parseAndVerifyAccessToken
Original author: @oscerd
Target branch: camel-4.18.x
Tracking issue: https://issues.apache.org/jira/browse/CAMEL-23504

The bug exists on camel-4.18.x with the same code shape as on mainKeycloakSecurityHelper.parseAndVerifyAccessToken builds a TokenVerifier with only SUBJECT_EXISTS_CHECK and a RealmUrlCheck, and Keycloak's TokenVerifier.withChecks(...) appends rather than replacing defaults, so TokenVerifier.IS_ACTIVE (the exp/nbf predicate) is never applied. Cherry-pick applied cleanly with auto-merge.

camel-4.14.x is not affected because the camel-keycloak component does not exist on that line (it was introduced in 4.15.0).

Verification

  • git cherry-pick 82fd4094b70 — clean auto-merge, no manual conflict resolution
  • mvn clean install -DskipTests -Dquickly from repo root — BUILD SUCCESS

Original description

See #23197.


Claude Code on behalf of Andrea Cosentino

…fyAccessToken

KeycloakSecurityHelper.parseAndVerifyAccessToken built its TokenVerifier
with only SUBJECT_EXISTS_CHECK and a RealmUrlCheck. The Keycloak
TokenVerifier starts with an empty internal check list and withChecks(...)
appends rather than replacing a default set, so the built-in IS_ACTIVE
predicate (which validates the exp and nbf claims) was not part of the
verification chain.

Add IS_ACTIVE to the withChecks(...) invocation so the helper enforces
the token's validity window in addition to signature, subject and issuer.

Two unit tests are added in KeycloakSecurityHelperTest:
* testParseAndVerifyAccessTokenRejectsExpiredToken signs a token whose
  exp claim is in the past and asserts that parseAndVerifyAccessToken
  throws VerificationException.
* testParseAndVerifyAccessTokenAcceptsValidToken signs an unexpired
  token and asserts that verification returns the parsed claims.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd requested review from davsclaus and orpiske May 14, 2026 07:32
@oscerd oscerd merged commit 7f4c473 into apache:camel-4.18.x May 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants