-
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
Implementations of OpaqueTokenIntrospector fail to URL encode client secret #15988
Comments
Thanks for this report, @joelossher. I agree that this should be taken care of. My primary concern is that there are applications like yours that are self-encoding already (like you are). To start encoding by default at this point would break those applications. Because there is a constructor that accepts a For that reason, I'll schedule this fix for 6.5. |
Are you able to provide a PR to add the encoding and a test? |
|
@ngocnhan-tran1996, my understanding is that the OAuth 2.0 spec indicates that the client id and secret should be URL encoded before performing the Basic Auth encoding of username and password together (pseudocode follows):
So this ticket would make it so that the values are URL encoded before formulating the Does that clarify, or am I misunderstanding your question? |
Let me make more clearly Line 88 in 9d2ca3d
And deep into this, it use String credentialsString = username + ":" + password;
byte[] encodedBytes = Base64.getEncoder().encode(credentialsString.getBytes(charset));
return new String(encodedBytes, charset); So if we want to encode password in side restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor(urlencode(clientId), urlencode(clientSecret))); This part confuses me, we need to encode from |
The encoding that Spring Framework provides is Base64 encoding. The OAuth spec indicates that the values should be URL encoded and then also thereafter Base64 encoded. If you look carefully at the Framework code, you'll see that it is doing:
which is different from
|
Thank for your explantion, can I work on this? |
Sure! Note that it is targeted for |
Describe the bug
Both the
SpringOpaqueTokenIntrospector
andNimbusOpaqueTokenIntrospector
use theclientId
andclientSecret
to authenticate the calls to the authorization server.This is done via basic authentication added using a
BasicAuthenticationInterceptor
. This does not perform any URL encoding.This issue was addressed in #9610 for the token granting client, but persists for the introspection client.
The workaround at the moment is to manually encode the secret when instantiating the introspector.
To Reproduce
badSecret%
SpringOpaqueTokenIntrospector
orNimbusOpaqueTokenIntrospector
to use that clientinvalid_request
error and see the following cause in the logs:Expected behavior
The token introspector should URL encode the secret.
The text was updated successfully, but these errors were encountered: