Skip to content

WebClientReactiveClientCredentialsTokenResponseClient should not set Authorization header when ClientAuthenticationMethod.POST #6911

Closed
@aaronjwhiteside

Description

@aaronjwhiteside

Summary

WebClientReactiveClientCredentialsTokenResponseClient always sets an Authorization header for basic auth even if the ClientAuthenticationMethod is POST.

Actual Behavior

ClientRegistration.withRegistrationId("xxxx)
     .clientAuthenticationMethod(ClientAuthenticationMethod.POST)
     // etc...

Results in a request being made to the tokenUri with Basic XXXX in the Authorization header.

Expected Behavior

There should be no Authorization header set at all, the client id and client secret should only be in the POST body.

Version

5.1.5.RELEASE

Looking at the code in WebClientReactiveClientCredentialsTokenResponseClient, it's obviously what the cause is:

	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());
			}
		};
	}

Looks like someone forgot to remove the first call to headers.setBasicAuth() when adding the check for ClientAuthenticationMethod == BASIC...

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions