|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
49 | 49 | import org.springframework.security.oauth2.jwt.ReactiveJwtDecoderFactory;
|
50 | 50 | import org.springframework.util.Assert;
|
51 | 51 | import org.springframework.util.StringUtils;
|
| 52 | +import org.springframework.web.reactive.function.client.WebClient; |
52 | 53 |
|
53 | 54 | /**
|
54 | 55 | * A {@link ReactiveJwtDecoderFactory factory} that provides a {@link ReactiveJwtDecoder}
|
@@ -89,6 +90,8 @@ public final class ReactiveOidcIdTokenDecoderFactory implements ReactiveJwtDecod
|
89 | 90 | private Function<ClientRegistration, Converter<Map<String, Object>, Map<String, Object>>> claimTypeConverterFactory = (
|
90 | 91 | clientRegistration) -> DEFAULT_CLAIM_TYPE_CONVERTER;
|
91 | 92 |
|
| 93 | + private Function<ClientRegistration, WebClient> webClientFactory = (clientRegistration) -> WebClient.create(); |
| 94 | + |
92 | 95 | /**
|
93 | 96 | * Returns the default {@link Converter}'s used for type conversion of claim values
|
94 | 97 | * for an {@link OidcIdToken}.
|
@@ -165,6 +168,7 @@ private NimbusReactiveJwtDecoder buildDecoder(ClientRegistration clientRegistrat
|
165 | 168 | }
|
166 | 169 | return NimbusReactiveJwtDecoder.withJwkSetUri(jwkSetUri)
|
167 | 170 | .jwsAlgorithm((SignatureAlgorithm) jwsAlgorithm)
|
| 171 | + .webClient(webClientFactory.apply(clientRegistration)) |
168 | 172 | .build();
|
169 | 173 | }
|
170 | 174 | if (jwsAlgorithm != null && MacAlgorithm.class.isAssignableFrom(jwsAlgorithm.getClass())) {
|
@@ -241,4 +245,19 @@ public void setClaimTypeConverterFactory(
|
241 | 245 | this.claimTypeConverterFactory = claimTypeConverterFactory;
|
242 | 246 | }
|
243 | 247 |
|
| 248 | + /** |
| 249 | + * Sets the factory that provides a {@link WebClient} used by |
| 250 | + * {@link NimbusReactiveJwtDecoder} to coordinate with the authorization servers |
| 251 | + * indicated in the <a href="https://tools.ietf.org/html/rfc7517#section-5">JWK |
| 252 | + * Set</a> uri. |
| 253 | + * @param webClientFactory the factory that provides a {@link WebClient} used by |
| 254 | + * {@link NimbusReactiveJwtDecoder} |
| 255 | + * |
| 256 | + * @since 6.3 |
| 257 | + */ |
| 258 | + public void setWebClientFactory(Function<ClientRegistration, WebClient> webClientFactory) { |
| 259 | + Assert.notNull(webClientFactory, "webClientFactory cannot be null"); |
| 260 | + this.webClientFactory = webClientFactory; |
| 261 | + } |
| 262 | + |
244 | 263 | }
|
0 commit comments