spring-projects / spring-projects/spring-security
Document configuration to support JWT Header TYP as "at+jwt"
@jzheaux is already working on this.
Since Sep 15, 2021.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Expected Behavior
Currently, if the JWT is having typ as "at+jwt", the token is rejected with message "Failed to authenticate since the JWT was invalid". I am aware that this has already been addressed in gh-9900 (which was declined for good reason)
As this validation is done in Nimbus library and according to https://bitbucket.org/connect2id/nimbus-jose-jwt/issues/366 will never validate "jwt+at" by default (Starting with v8.0 the acceptable typ header values must be set explicitly), at least it should be documented in Spring Security reference docs how to reconfigure Nimbus for validating "jwt+at" like this:
@Bean
JwtDecoder jwtDecoder() {
DefaultJOSEObjectTypeVerifier<SecurityContext> verifier =
new DefaultJOSEObjectTypeVerifier<>(new JOSEObjectType("at+jwt"));
NimbusJwtDecoder decoder = NimbusJwtDecoder.withJwkSetUri(this.uri)
.jwtProcessorCustomizer((processor) -> processor.setJWSTypeVerifier(verifier))
.build()
// ... any other decoder settings
return decoder;
}
Current Behavior
Currently, such token is rejected with the message "Failed to authenticate since the JWT was invalid" and the documentation does not have any section for configuring this as referenced in gh-9900.
To solve this currently, developers have to search spring security issues to find a solution because this is not documented in the spring security reference documentation.
Context
As the corresponding IETF specification for JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens has already been approved by the IESG and will be published as final RFC soon I expect more authorization server implementations issuing JWT tokens that are compliant to this new RFC.
I could also help to provide a PR for extending the documentation (maybe as part of section 12.3.10. Configuring Validation)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.