client_credentials client should not set Authorization header when ClientAuthenticationMethod.POST
Fixes gh-6911
This commit is contained in:
parent
6148eef689
commit
38ba70bbdd
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -91,7 +91,6 @@ public class WebClientReactiveClientCredentialsTokenResponseClient implements Re
|
|||
private Consumer<HttpHeaders> headers(ClientRegistration clientRegistration) {
|
||||
return headers -> {
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
headers.setBasicAuth(clientRegistration.getClientId(), clientRegistration.getClientSecret());
|
||||
if (ClientAuthenticationMethod.BASIC.equals(clientRegistration.getClientAuthenticationMethod())) {
|
||||
headers.setBasicAuth(clientRegistration.getClientId(), clientRegistration.getClientSecret());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -98,9 +98,11 @@ public class WebClientReactiveClientCredentialsTokenResponseClientTests {
|
|||
OAuth2ClientCredentialsGrantRequest request = new OAuth2ClientCredentialsGrantRequest(registration);
|
||||
|
||||
OAuth2AccessTokenResponse response = this.client.getTokenResponse(request).block();
|
||||
String body = this.server.takeRequest().getUtf8Body();
|
||||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
String body = actualRequest.getUtf8Body();
|
||||
|
||||
assertThat(response.getAccessToken()).isNotNull();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION)).isNull();
|
||||
assertThat(body).isEqualTo("grant_type=client_credentials&scope=read%3Auser&client_id=client-id&client_secret=client-secret");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue