Commit 7bbeeaa4 authored by Madhura Bhave's avatar Madhura Bhave

Fix build following Spring Security changes

parent 8fd8a9b6
...@@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2Res ...@@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2Res
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration; 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.JwtDecoder;
import org.springframework.security.oauth2.jwt.JwtDecoders; import org.springframework.security.oauth2.jwt.JwtDecoders;
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder; import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
...@@ -53,7 +54,8 @@ class OAuth2ResourceServerJwtConfiguration { ...@@ -53,7 +54,8 @@ class OAuth2ResourceServerJwtConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public JwtDecoder jwtDecoderByJwkKeySetUri() { public JwtDecoder jwtDecoderByJwkKeySetUri() {
return NimbusJwtDecoder.withJwkSetUri(this.properties.getJwkSetUri()) return NimbusJwtDecoder.withJwkSetUri(this.properties.getJwkSetUri())
.jwsAlgorithm(this.properties.getJwsAlgorithm()).build(); .jwsAlgorithm(SignatureAlgorithm.from(this.properties.getJwsAlgorithm()))
.build();
} }
@Bean @Bean
......
...@@ -102,7 +102,7 @@ public class OAuth2ResourceServerAutoConfigurationTests { ...@@ -102,7 +102,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
public void autoConfigurationShouldConfigureResourceServerWithJwsAlgorithm() { public void autoConfigurationShouldConfigureResourceServerWithJwsAlgorithm() {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com", "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) -> { .run((context) -> {
JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class); JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class);
Object processor = ReflectionTestUtils.getField(jwtDecoder, Object processor = ReflectionTestUtils.getField(jwtDecoder,
...@@ -110,7 +110,7 @@ public class OAuth2ResourceServerAutoConfigurationTests { ...@@ -110,7 +110,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
Object keySelector = ReflectionTestUtils.getField(processor, Object keySelector = ReflectionTestUtils.getField(processor,
"jwsKeySelector"); "jwsKeySelector");
assertThat(keySelector).hasFieldOrPropertyWithValue("jwsAlg", assertThat(keySelector).hasFieldOrPropertyWithValue("jwsAlg",
JWSAlgorithm.HS512); JWSAlgorithm.RS384);
assertThat(getBearerTokenFilter(context)).isNotNull(); assertThat(getBearerTokenFilter(context)).isNotNull();
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment