Fix build following Spring Security changes

This commit is contained in:
Madhura Bhave 2019-04-12 12:24:35 -07:00
parent 8fd8a9b618
commit 7bbeeaa4d2
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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();
});
}