-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for JWT Header TYP as "at+jwt" #9900
Comments
@jzheaux can you please have a look if this is bug or this needs enhancement in library? Thanks in advance. |
The reason for this behavior is Nimbus defaults to checking that the To get your resource server to accept @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;
} For passivity reasons, I imagine that Spring Security will continue to use the Nimbus defaults. Once the draft gets finalized, there may be an opportunity to make this configuration simpler. |
@jzheaux The draft has now been published as RFC 9068 (and I am running into this problem, thanks for the configuration hint, however :-)) |
In light of a separate request from @ymajoros, I think it would be good to revisit this decision, now that the spec is finalized. Allowing the I think this would fit nicely into @Bean
JwtDecoder jwtDecoder() {
NimbusJwtDecoder jwtDecoder = NimbusJwtDecoder.withIssuerLocation("http://issuer").build();
jwtDecoder.setJwtValidator(JwtValidators.createDefaultForIssuer("http://issuer"));
return jwtDecoder;
} where these factory methods change to check the In this case, This changes how |
@ymajoros, thank you very much for the PR. I don't think that it should be in |
After spending some more time on it, I'm not convinced we can do more validation for now, according to RFC 9068 (at+jwt) and RFC 7519 (jwt):
So, I think the current implementation is enough. I'd just add the optional application/ prefix. |
@ymajoros If it isn't already, I think it should be possible to configure the expected audience values. At least it wouldn't allow tokens leaked by one service (i.e. in a microservice architecture) to be successfully used against another service. |
@shartte true, but that seems out of scope for this issue and a different feature that should also be implemented, isn't it? |
@jzheaux can you look at it again in light of my previous comments? |
Is there any update on "at+jwt" support ? |
Is there any recommended workaround? |
Any updates on this one @jzheaux? We've used the following workaround in our application:
This approach works well when using either |
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". Spring Security Oauth2 Resource Server with JWT as bearer token should accept typ as "at+jwt" as well.
Current 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".
My Authorization server is issuing JWT access token with typ as "at+jwt" as per the following draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-access-token-jwt-11
How has this issue affected you? JWT token is rejected although this is correct as per Authorization server
What are you trying to accomplish? Validate JWT Bearer token using Spring Security OAuth2 Resource Server capabilities.
What other alternatives have you considered? At this point, in the documentation I didn;t find a way where I can customize the JWT Validator. Although, documentation is around our own Audience or other validations once the JWT is accepted by Spring Security.
Are you aware of any workarounds? Not at this point of time.
The text was updated successfully, but these errors were encountered: