Skip to content

Conversation

@ziqin
Copy link
Contributor

@ziqin ziqin commented Dec 5, 2025

This PR fixes gh-18269 by passing a constant string "JWT" to JwsHeader.Builder::type(String type).

This PR doesn't generate RFC 9068 compliant JWT access tokens. Should we add a configuration method to NimbusJwtEncoder and SecretKeyJwtEncoderBuilder / RsaKeyPairJwtEncoderBuilder / EcKeyPairJwtEncoderBuilder to support generating RFC 9068 JWT access tokens?

I am not sure whether it affects compatibility with the existing support for RFC 9068, e.g., the JwtValidators.AtJwtBuilder.

ziqin added 2 commits December 5, 2025 21:18
This test encodes an JWT with NimbusJwtEncoder, and then decodes it with
NimbusJwtDecoder.

This test will fail when NimbusJwtEncoder emits a JWT with a wrong `typ'
parameter in the header, as NimbusJwtDecoder validates the JWT with
JwtTypeValidator by default.  It may be beneficial for finding out other
similiar bugs too.

Signed-off-by: Ziqin Wang <ziqin@wangziqin.net>
Closes spring-projectsgh-18269

Signed-off-by: Ziqin Wang <ziqin@wangziqin.net>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 5, 2025
@ziqin ziqin marked this pull request as ready for review December 5, 2025 13:47
Issue spring-projectsgh-18269

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
@jzheaux
Copy link
Contributor

jzheaux commented Dec 15, 2025

Thanks for the PR, @ziqin. Will you please open a separate ticket to discuss handling the JWT type and RFC 9068 tokens?

@jzheaux jzheaux self-assigned this Dec 15, 2025
@jzheaux jzheaux added type: bug A general bug in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 15, 2025
@jzheaux jzheaux added this to the 7.0.1 milestone Dec 15, 2025
@jzheaux jzheaux merged commit 964fcac into spring-projects:main Dec 15, 2025
6 checks passed
@jzheaux
Copy link
Contributor

jzheaux commented Dec 15, 2025

Thanks for the PR, @ziqin! This is now merged into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NimbusJwtEncoder produces JWT with wrong "typ" header value

3 participants