Polish "Configure Issuer Validator for Resource Server"

See gh-17952
This commit is contained in:
Madhura Bhave
2019-08-23 19:31:58 -07:00
parent b3d189cf87
commit 28d374d84d
4 changed files with 10 additions and 6 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.security.oauth2.jwt.ReactiveJwtDecoders;
*
* @author Madhura Bhave
* @author Artsiom Yudovin
* @author HaiTao Zhang
*/
@Configuration
class ReactiveOAuth2ResourceServerJwkConfiguration {
@@ -48,9 +49,9 @@ class ReactiveOAuth2ResourceServerJwkConfiguration {
public ReactiveJwtDecoder jwtDecoder() {
NimbusReactiveJwtDecoder nimbusReactiveJwtDecoder = new NimbusReactiveJwtDecoder(
this.properties.getJwt().getJwkSetUri());
if (this.properties.getJwt().getIssuerUri() != null) {
nimbusReactiveJwtDecoder
.setJwtValidator(JwtValidators.createDefaultWithIssuer(this.properties.getJwt().getIssuerUri()));
String issuerUri = this.properties.getJwt().getIssuerUri();
if (issuerUri != null) {
nimbusReactiveJwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(issuerUri));
}
return nimbusReactiveJwtDecoder;
}

View File

@@ -33,6 +33,7 @@ import org.springframework.security.oauth2.jwt.NimbusJwtDecoderJwkSupport;
*
* @author Madhura Bhave
* @author Artsiom Yudovin
* @author HaiTao Zhang
*/
@Configuration
class OAuth2ResourceServerJwtConfiguration {
@@ -49,9 +50,9 @@ class OAuth2ResourceServerJwtConfiguration {
public JwtDecoder jwtDecoderByJwkKeySetUri() {
NimbusJwtDecoderJwkSupport nimbusJwtDecoder = new NimbusJwtDecoderJwkSupport(
this.properties.getJwt().getJwkSetUri());
if (this.properties.getJwt().getIssuerUri() != null) {
nimbusJwtDecoder
.setJwtValidator(JwtValidators.createDefaultWithIssuer(this.properties.getJwt().getIssuerUri()));
String issuerUri = this.properties.getJwt().getIssuerUri();
if (issuerUri != null) {
nimbusJwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(issuerUri));
}
return nimbusJwtDecoder;
}

View File

@@ -65,6 +65,7 @@ import static org.mockito.Mockito.mock;
*
* @author Madhura Bhave
* @author Artsiom Yudovin
* @author HaiTao Zhang
*/
public class ReactiveOAuth2ResourceServerAutoConfigurationTests {

View File

@@ -61,6 +61,7 @@ import static org.mockito.Mockito.mock;
*
* @author Madhura Bhave
* @author Artsiom Yudovin
* @author HaiTao Zhang
*/
public class OAuth2ResourceServerAutoConfigurationTests {