|
|
|
@ -20,10 +20,12 @@ import java.util.Collection;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.nimbusds.jose.JWSAlgorithm;
|
|
|
|
|
import okhttp3.mockwebserver.MockResponse;
|
|
|
|
|
import okhttp3.mockwebserver.MockWebServer;
|
|
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
|
@ -68,6 +70,7 @@ import static org.mockito.Mockito.mock;
|
|
|
|
|
* @author Madhura Bhave
|
|
|
|
|
* @author Artsiom Yudovin
|
|
|
|
|
* @author HaiTao Zhang
|
|
|
|
|
* @author Anastasiia Losieva
|
|
|
|
|
*/
|
|
|
|
|
class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
@ -94,6 +97,31 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Test
|
|
|
|
|
void autoConfigurationUsingJwkSetUriShouldConfigureResourceServerUsingJwsAlgorithm() {
|
|
|
|
|
this.contextRunner
|
|
|
|
|
.withPropertyValues("spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://jwk-set-uri.com",
|
|
|
|
|
"spring.security.oauth2.resourceserver.jwt.jws-algorithm=RS512")
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = context.getBean(NimbusReactiveJwtDecoder.class);
|
|
|
|
|
assertThat(nimbusReactiveJwtDecoder).extracting("jwtProcessor.arg$2")
|
|
|
|
|
.matches((algorithms) -> ((Set<JWSAlgorithm>) algorithms).contains(JWSAlgorithm.RS512));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingJwsAlgorithm() {
|
|
|
|
|
this.contextRunner.withPropertyValues(
|
|
|
|
|
"spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location",
|
|
|
|
|
"spring.security.oauth2.resourceserver.jwt.jws-algorithm=RS384").run((context) -> {
|
|
|
|
|
NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = context.getBean(NimbusReactiveJwtDecoder.class);
|
|
|
|
|
assertThat(nimbusReactiveJwtDecoder)
|
|
|
|
|
.extracting("jwtProcessor.arg$1.jwsKeySelector.expectedJwsAlgorithm")
|
|
|
|
|
.isEqualTo(JWSAlgorithm.RS384);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void autoConfigurationShouldConfigureResourceServerUsingOidcIssuerUri() throws IOException {
|
|
|
|
|
this.server = new MockWebServer();
|
|
|
|
|