Skip to content

CAMEL-23504: camel-keycloak - include IS_ACTIVE check in parseAndVerifyAccessToken#23197

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23504
May 14, 2026
Merged

CAMEL-23504: camel-keycloak - include IS_ACTIVE check in parseAndVerifyAccessToken#23197
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23504

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 13, 2026

Summary

KeycloakSecurityHelper.parseAndVerifyAccessToken built its TokenVerifier
with only SUBJECT_EXISTS_CHECK and a RealmUrlCheck. Keycloak's
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.

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

Tracking issue: https://issues.apache.org/jira/browse/CAMEL-23504

Changes

  • KeycloakSecurityHelper.java: include TokenVerifier.IS_ACTIVE in the
    .withChecks(...) call.
  • KeycloakSecurityHelperTest.java: two new tests
    • testParseAndVerifyAccessTokenRejectsExpiredToken — signs a token whose
      exp claim is one hour in the past with an RSA key and asserts that
      parseAndVerifyAccessToken throws VerificationException.
    • testParseAndVerifyAccessTokenAcceptsValidToken — signs an unexpired
      token and asserts verification returns the parsed claims (happy-path
      regression test).

Test plan

  • mvn install in components/camel-keycloak — 16/16 tests pass
  • mvn clean install -DskipTests -Dquickly from repo root — BUILD SUCCESS

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 13, 2026 16:42
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-keycloak
All tested modules (8 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Keycloak
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@oscerd oscerd merged commit 39133b1 into apache:main May 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants