{
"cause":null,
"stackTrace":[
{
"classLoaderName":"app",
"moduleName":null,
"moduleVersion":null,
"methodName":"authenticate",
"fileName":"JwtAuthenticationProvider.java",
"lineNumber":86,
"nativeMethod":false,
"className":"org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider"
},
{
"classLoaderName":"app",
"moduleName":null,
"moduleVersion":null,
"methodName":"authenticate",
"fileName":"ProviderManager.java",
"lineNumber":199,
"nativeMethod":false,
"className":"org.springframework.security.authentication.ProviderManager"
},
{
"classLoaderName":"app",
"moduleName":null,
"moduleVersion":null,
"methodName":"doFilterInternal",
"fileName":"BearerTokenAuthenticationFilter.java",
"lineNumber":124,
"nativeMethod":false,
"className":"org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter"
}
// ... [snip]
],
"title":"Unauthorized",
"status":"UNAUTHORIZED",
"detail":"An error occurred while attempting to decode the Jwt: JOSE header \"typ\" (type) \"JWS\" not allowed"
}
Spring Boot 2.3.x.RELEASE applies additional non-standard validation on JWT tokens due to upgrade to NimbusDS 8.x.
With Spring Boot 2.2.2.RELEASE a JWT token with header field
typ: "JWS"validates fine. In Spring Boot 2.3.0.RELEASE such a token is rejected due to a breaking change in NimbusDS 8.x, which requirestypto be set to eitherJWTor omitted.As per RFC 7515 there's no dedicated
typmandated.The issue is that the builder design in
NimbusJwtDecoder(in my caseNimbusJwtDecoder.withPublicKey(publicKey).build()) does not allow to go back to the old behavior, nor does it allow to change theJWSTypeVerifier/JWETypeVerifierset in NimbusDS'sDefaultJWTProcessor. Therefore, it is currently necessary to duplicate the complete builder code, which is making me uneasy considering it's a security relevant part and a future change in Spring Security/Nimbus might render my code insecure.Current Behavior
JWT tokens with
typ: JWSare refused since Spring Boot 2.3.xExpected Behavior
Either one of:
Context
Dependency:
org.springframework.security:spring-security-oauth2-jose:5.3.3.RELEASEClass:
org.springframework.security.oauth2.jwt.NimbusJwtDecoderUnfortunately, I am not in control of the authorization server, which generates these custom JWTs. At the same time, I do not want to copy security relevant code.
Possible solutions:
JWSTypeVerifier/JWETypeVerifierto no-op verifiers in the builder(s)Stacktrace