|
63 | 63 | public abstract class AbstractWebClientReactiveOAuth2AccessTokenResponseClient<T extends AbstractOAuth2AuthorizationGrantRequest>
|
64 | 64 | implements ReactiveOAuth2AccessTokenResponseClient<T> {
|
65 | 65 |
|
| 66 | + private boolean encodeClientCredentials = true; |
| 67 | + |
66 | 68 | private WebClient webClient = WebClient.builder().build();
|
67 | 69 |
|
68 | 70 | AbstractWebClientReactiveOAuth2AccessTokenResponseClient() {
|
@@ -100,8 +102,11 @@ private void populateTokenRequestHeaders(T grantRequest, HttpHeaders headers) {
|
100 | 102 | headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
101 | 103 | if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.equals(clientRegistration.getClientAuthenticationMethod())
|
102 | 104 | || ClientAuthenticationMethod.BASIC.equals(clientRegistration.getClientAuthenticationMethod())) {
|
103 |
| - String clientId = encodeClientCredential(clientRegistration.getClientId()); |
104 |
| - String clientSecret = encodeClientCredential(clientRegistration.getClientSecret()); |
| 105 | + String clientId = this.encodeClientCredentials ? encodeClientCredential(clientRegistration.getClientId()) |
| 106 | + : clientRegistration.getClientId(); |
| 107 | + String clientSecret = this.encodeClientCredentials |
| 108 | + ? encodeClientCredential(clientRegistration.getClientSecret()) |
| 109 | + : clientRegistration.getClientSecret(); |
105 | 110 | headers.setBasicAuth(clientId, clientSecret);
|
106 | 111 | }
|
107 | 112 | }
|
@@ -230,4 +235,17 @@ public void setWebClient(WebClient webClient) {
|
230 | 235 | this.webClient = webClient;
|
231 | 236 | }
|
232 | 237 |
|
| 238 | + /** |
| 239 | + * Sets the flag that controls whether client credentials are encoded using the |
| 240 | + * application/x-www-form-urlencoded algorithm while populating token request headers. |
| 241 | + * @deprecated Support for non-compliant providers will be removed in Spring Security |
| 242 | + * 5.6 |
| 243 | + * @param encodeClientCredentials {@code false} to disable encoding client credentials |
| 244 | + * (default is true) |
| 245 | + */ |
| 246 | + @Deprecated |
| 247 | + public void setEncodeClientCredentials(boolean encodeClientCredentials) { |
| 248 | + this.encodeClientCredentials = encodeClientCredentials; |
| 249 | + } |
| 250 | + |
233 | 251 | }
|
0 commit comments