Skip to content

CAMEL-23760: camel-oauth - require a JWK set to verify token signatures in UserProfile#24032

Open
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23760-oauth-jwks
Open

CAMEL-23760: camel-oauth - require a JWK set to verify token signatures in UserProfile#24032
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23760-oauth-jwks

Conversation

@oscerd

@oscerd oscerd commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

The camel-oauth UserProfile token verification skipped the JWS signature check when the configured JWK set was missing or empty, leaving the signature unverified in that case. This makes the signature check mandatory:

  • When no JWK set is available (null or empty), the token is now rejected with an OAuthException rather than accepted.
  • Deployments with a correctly resolved JWK set are unaffected.
  • This aligns the legacy UserProfile path with the JwtTokenValidator SPI path, which already fails closed on this condition.

Behaviour change

Documented in the 4.21 upgrade guide.

Testing

Adds UserProfileTest with three cases: rejection on an empty JWK set, rejection on a missing JWK set, and acceptance when the signature verifies against a matching key.

Claude Code on behalf of Andrea Cosentino.

🤖 Generated with Claude Code

…es in UserProfile

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oscerd oscerd requested review from gnodet and luigidemasi June 15, 2026 13:33

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice security hardening — the fail-closed approach aligns UserProfile with the JwtTokenValidator SPI path and closes a real gap where tokens could be accepted without signature verification.

No blocking issues found. Two minor suggestions inline.

Note: CI checks have not reported yet on this branch — please verify green before merging.

This review does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analyzers (SonarCloud).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@@ -180,15 +180,16 @@ private static JsonObject verifyToken(OAuthConfig config, String token, boolean

// Fetch Keycloak public key

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment is a leftover from when the code was Keycloak-specific. The verification is now provider-agnostic (works with any OIDC IdP). Consider updating:

Suggested change
// Fetch Keycloak public key
// Verify JWS signature against configured JWK set

if (!signedJWT.verify(new RSASSAVerifier(publicKey))) {
throw new OAuthException("Invalid token signature");
}
if (jwkSet == null || jwkSet.isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch adding the null check here — the old code would have thrown an NPE if getJWKSet() returned null (which it can, since OAuthConfig.jwkSet has no default). This is a correctness fix beyond the stated scope of the PR and worth calling out in the description.

@luigidemasi luigidemasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

3 participants