diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java index 08dc972cfd..3bfe1c50fd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java @@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2Res import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.jose.jws.SignatureAlgorithm; import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.security.oauth2.jwt.JwtDecoders; import org.springframework.security.oauth2.jwt.NimbusJwtDecoder; @@ -53,7 +54,8 @@ class OAuth2ResourceServerJwtConfiguration { @ConditionalOnMissingBean public JwtDecoder jwtDecoderByJwkKeySetUri() { return NimbusJwtDecoder.withJwkSetUri(this.properties.getJwkSetUri()) - .jwsAlgorithm(this.properties.getJwsAlgorithm()).build(); + .jwsAlgorithm(SignatureAlgorithm.from(this.properties.getJwsAlgorithm())) + .build(); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java index 3bf9a6c295..fd7e267efd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java @@ -102,7 +102,7 @@ public class OAuth2ResourceServerAutoConfigurationTests { public void autoConfigurationShouldConfigureResourceServerWithJwsAlgorithm() { this.contextRunner.withPropertyValues( "spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", - "spring.security.oauth2.resourceserver.jwt.jws-algorithm=HS512") + "spring.security.oauth2.resourceserver.jwt.jws-algorithm=RS384") .run((context) -> { JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); Object processor = ReflectionTestUtils.getField(jwtDecoder, @@ -110,7 +110,7 @@ public class OAuth2ResourceServerAutoConfigurationTests { Object keySelector = ReflectionTestUtils.getField(processor, "jwsKeySelector"); assertThat(keySelector).hasFieldOrPropertyWithValue("jwsAlg", - JWSAlgorithm.HS512); + JWSAlgorithm.RS384); assertThat(getBearerTokenFilter(context)).isNotNull(); }); }