Skip to content

Fix RFC 9068 compliance: set typ header to at+jwt for JWT access tokens#2948

Open
gnodet wants to merge 1 commit intomainfrom
fix/rfc9068-at-jwt-type
Open

Fix RFC 9068 compliance: set typ header to at+jwt for JWT access tokens#2948
gnodet wants to merge 1 commit intomainfrom
fix/rfc9068-at-jwt-type

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 11, 2026

Summary

CXF supports JWT-formatted access tokens via useJwtFormatForAccessTokens, but the produced tokens are missing the typ: at+jwt header required by RFC 9068 Section 2.1:

The JWT MUST contain a typ header parameter with the value at+jwt

Without this header, any RFC 9068-compliant resource server would reject CXF-issued JWT access tokens. This is a spec compliance bug.

Changes

  • JoseConstants: Added TYPE_AT_JWT = "at+jwt" constant
  • JoseType: Added AT_JWT enum member with proper getType() lookup (since at+jwt can't be a Java identifier, it needs explicit handling like JOSE_JSON)
  • AbstractOAuthDataProvider.processJwtAccessToken(): Sets the at+jwt type on both JWS and JWE headers, handling both the sign-only and sign+encrypt cases per RFC 9068 Section 2.1 and Section 4

This is a proper implementation incorporating @reta's review feedback from #990 (using the type system properly and handling both JWS and JWE).

Closes #990

Test plan

  • JwsCompactReaderWriterTest — passes
  • OAuth2JwtFiltersTest — 5 tests pass
  • JAXRSOAuth2TlsTest — 5 tests pass

🤖 Generated with Claude Code

Per RFC 9068 Section 2.1, JWT access tokens MUST include a typ
header parameter set to "at+jwt". This change:

- Adds TYPE_AT_JWT constant to JoseConstants
- Adds AT_JWT member to JoseType enum with proper lookup
- Sets the at+jwt type on both JWS and JWE headers when producing
  JWT access tokens in AbstractOAuthDataProvider

Closes #990

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@reta
Copy link
Member

reta commented Mar 11, 2026

@coheigea could you please help me to validate this pull request? I will also take a look, thank you

@gnodet gnodet changed the title RFC 9068: Set typ header to at+jwt for JWT access tokens Fix RFC 9068 compliance: set typ header to at+jwt for JWT access tokens Mar 11, 2026
@gnodet gnodet added the bug label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants