-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Description
After upgrading to Spring Boot 4 the behavior of JwkSetUriJwtDecoderBuilderCustomizer has changed. It is no longer possible to disable JWT type header validation . The customizer appears to be ignored, and the resulting JwtDecoder still enforces type validation.
Spring Boot v4.0.0
Jdk v25
Module spring-boot-starter-security-oauth2-resource-server v4.0.0
Properties: spring.security.resourceserver.jwt.issuer-uri: https://identity-stage.aaaa.com
In previous versions Spring Boot 3.5.x the following configuration worked as expected:
public final class CustomDecoderBuilderCustomizer implements JwkSetUriJwtDecoderBuilderCustomizer {
@Override
public void customize(NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder builder) {
builder.validateType(false);
}
}After the upgrade, this customization is not applied, and the decoder continues validating the typ header. This results in rejected tokens that previously worked.
Authentication failed with provider JwtAuthenticationProvider since An error occurred while attempting to decode the Jwt: the given typ value needs to be one of [JWT]
While debugging, I noticed that during the creation of the JwtDecoder bean, four validators are added, including JwtTypeValidator, in OAuth2ResourceServerJwtConfiguration#jwtDecoderByIssuerUri().
