Skip to content

Commit 382e701

Browse files
committed
Add functionality to set custom web client in ReactiveOidcIdTokenDecoderFactory and that custom web client ultimately is used by NimbusReactiveJwtDecoder (spring-projectsgh-13274)
1 parent 25e6c51 commit 382e701

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/ReactiveOidcIdTokenDecoderFactory.java

+14
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.springframework.security.oauth2.jwt.ReactiveJwtDecoderFactory;
5050
import org.springframework.util.Assert;
5151
import org.springframework.util.StringUtils;
52+
import org.springframework.web.reactive.function.client.WebClient;
5253

5354
/**
5455
* A {@link ReactiveJwtDecoderFactory factory} that provides a {@link ReactiveJwtDecoder}
@@ -89,6 +90,7 @@ public final class ReactiveOidcIdTokenDecoderFactory implements ReactiveJwtDecod
8990
private Function<ClientRegistration, Converter<Map<String, Object>, Map<String, Object>>> claimTypeConverterFactory = (
9091
clientRegistration) -> DEFAULT_CLAIM_TYPE_CONVERTER;
9192

93+
private WebClient webClient = WebClient.create();
9294
/**
9395
* Returns the default {@link Converter}'s used for type conversion of claim values
9496
* for an {@link OidcIdToken}.
@@ -164,6 +166,7 @@ private NimbusReactiveJwtDecoder buildDecoder(ClientRegistration clientRegistrat
164166
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString());
165167
}
166168
return NimbusReactiveJwtDecoder.withJwkSetUri(jwkSetUri).jwsAlgorithm((SignatureAlgorithm) jwsAlgorithm)
169+
.webClient(webClient)
167170
.build();
168171
}
169172
if (jwsAlgorithm != null && MacAlgorithm.class.isAssignableFrom(jwsAlgorithm.getClass())) {
@@ -239,4 +242,15 @@ public void setClaimTypeConverterFactory(
239242
this.claimTypeConverterFactory = claimTypeConverterFactory;
240243
}
241244

245+
/**
246+
* Sets the custom web client that will be used in {@link NimbusReactiveJwtDecoder}.
247+
* The default webClient is created by {@code WebClient.create()}.
248+
* This is optional method if we need to set custom web client in {@link NimbusReactiveJwtDecoder}.
249+
*
250+
* @param webClient webclient
251+
*/
252+
public void setWebClient(WebClient webClient) {
253+
this.webClient = webClient;
254+
}
255+
242256
}

0 commit comments

Comments
 (0)