-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional client_id field added in POST body for private_key_jwt authentication method for client credential grant type #11298
Comments
I was able to fix the issue by customizing WebClientReactiveClientCredentialsTokenResponseClient since client_id gets added in method populateTokenRequestBody(). Is there a cleaner solution than this ?
|
@mit2222, thanks for reaching out! I see the issue you're facing here. It does appear as though
Having said that, it's possible this could be addressed in 5.8 or 6.0 by changing the behavior of Was your workaround to copy the code from |
@sjohnr I just created a custom class by copying contents from WebClientReactiveClientCredentialsTokenResponseClient as well as AbstractWebClientReactiveOAuth2AccessTokenResponseClient. In custom AbstractWebClientReactiveOAuth2AccessTokenResponseClient I just removed the portion from if class where client_id is added |
@sjohnr can you provide which dependency can I use whic has 5.8 and 6.0. I can probably try it out. |
@MitCoder, 5.8 and 6.0 are unreleased, but you can clone the repo and look at the Create the package public class CustomWebClientReactiveClientCredentialsTokenResponseClient
extends WebClientReactiveClientCredentialsTokenResponseClient {
@Override
BodyInserters.FormInserter<String> populateTokenRequestBody(
OAuth2ClientCredentialsGrantRequest grantRequest,
BodyInserters.FormInserter<String> body) {
ClientRegistration clientRegistration =
ClientRegistration.withClientRegistration(clientRegistration(grantRequest))
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
.build();
OAuth2ClientCredentialsGrantRequest updatedGrantRequest =
new OAuth2ClientCredentialsGrantRequest(clientRegistration);
return super.populateTokenRequestBody(updatedGrantRequest, body);
}
} This works because the methods are package-private (default visibility) but not completely private. It creates a temporary |
@mit2222 If The client registration at the provider (Okta) must contain metadata that contains the public key used to verify the Jwt client assertion. The public key may be registered with the client metadata or it may be exposed at the client application via a I suspect Okta does not require the |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
@jgrandja The client application which uses Signed JWT is created on Okta and it stores the public and private key. I use the same public and private key configuration in jwkResolver. I verified the jwk-set-uri and it doesnt have the public key that is being used in jwkResolver. |
@mit2222 I tested this out with Okta and I was able to reproduce the following error:
Removing the As a temporary workaround, you can supply the following custom implementation of public class CustomWebClientReactiveClientCredentialsTokenResponseClient
extends WebClientReactiveClientCredentialsTokenResponseClient {
@Override
BodyInserters.FormInserter<String> populateTokenRequestBody(
OAuth2ClientCredentialsGrantRequest grantRequest,
BodyInserters.FormInserter<String> body) {
Set<String> scopes = scopes(grantRequest);
if (!CollectionUtils.isEmpty(scopes)) {
body.with(OAuth2ParameterNames.SCOPE, StringUtils.collectionToDelimitedString(scopes, " "));
}
return body;
}
} As noted in @sjohnr comment, this custom implementation must reside in the package @sjohnr We should consider adding a hook for customizing the default body parameters. Similar to |
This commit refactors and aligns usage of the parametersConverter in AbstractWebClientReactiveOAuth2AccessTokenResponseClient with the same capability in AbstractOAuth2AuthorizationGrantRequestEntityConverter in order to align Reactive with Servlet for better consistency. Closes spring-projectsgh-11298
This commit refactors and aligns usage of the parametersConverter in AbstractWebClientReactiveOAuth2AccessTokenResponseClient with the same capability in AbstractOAuth2AuthorizationGrantRequestEntityConverter in order to align Reactive with Servlet for better consistency. Issue spring-projectsgh-11298
This commit refactors and aligns usage of the parametersConverter in AbstractWebClientReactiveOAuth2AccessTokenResponseClient with the same capability in AbstractOAuth2AuthorizationGrantRequestEntityConverter in order to align Reactive with Servlet for better consistency. Issue spring-projectsgh-11298
This commit refactors and aligns usage of the parametersConverter in AbstractWebClientReactiveOAuth2AccessTokenResponseClient with the same capability in AbstractOAuth2AuthorizationGrantRequestEntityConverter in order to align Reactive with Servlet for better consistency. Issue spring-projectsgh-11298
This commit refactors and aligns usage of the parametersConverter in AbstractWebClientReactiveOAuth2AccessTokenResponseClient with the same capability in AbstractOAuth2AuthorizationGrantRequestEntityConverter in order to align Reactive with Servlet for better consistency. Closes spring-projectsgh-11298
Describe the bug
I specifically want to use WebClientReactiveClientCredentialsTokenResponseClient because it provides WebClient to integrate with Okta api with client credentials private_key_jwt. Okta's /v1/token url needs client_assertion_type of urn:ietf:params:oauth:client-assertion-type:jwt-bearer, grant type as client_credentials and authentication method as PRIVATE_KEY_JWT.
To Reproduce
I would like to retrieve access token via client_credentials private_key_jwt flow through Spring Boot WebClient in-memory solution.
Upon debugging, client_id gets added as a result of which the body consists client_assertion, client_assertion_type, scope,grant_type and client_id due to AbstractWebClientReactiveOAuth2AccessTokenResponseClient class populateTokenRequestBody() private method.
I tried to manually integrate with Okta v1/token url through postman with client_assertion value retrieved from jwksResolver and I do get a valid Bearer token.
Expected behavior
I get below error
I have the below bean configurations.
The text was updated successfully, but these errors were encountered: