Closed
Description
Describe the bug
/oauth2/token
endpoint parameter code
url decode.
To Reproduce
- I get
code
from/oauth2/authorize
endpoint redirect url paramters. The code isIz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY%3D
- And I use the code post
/oauth2/token
, it will give me a error
{
"error": "invalid_grant"
}
- I try to use url decode
Iz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY%3D
, the right code isIz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY=
. And use new code to post, it work.
Expected behavior
I will get the code
from url parameter. The code will encode by Base64StringKeyGenerator.
I expect spring security
to help me decode the code
parameter., otherwise every client must decode it.
Maybe I can decode it when not null., or let me custom codeGenerator
.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
louiemondot commentedon Aug 25, 2020
I like to have a go at this one if that's possible.
[-]/oauth2/token endpoint parameter code url decode.[/-][+]/oauth2/token endpoint parameter validate.[/+]lizhongyue248 commentedon Aug 25, 2020
Describe the bug
I get a error when access
/oauth2/token
withclient_id
.To Reproduce
/oauth2/token
withclient_id
, I get a error:Debug the code:
When I post with
client_id
, the getPrincipal() isString
When I post without
client_id
, the the getPrincipal() isOAuth2ClientAuthenticationToken
andisAuthenticated
isfalse
.Expect havior
Please see RFC-6749 section-4.1.3.
The request header has Client Certificate. If the client post with
client_id
, the authorization server should ignore it or validate it, Instead of just throwing an error.SoulMate1214 commentedon Aug 28, 2020
Don't carry parameters clientId Inside the header,ohhhhhhhh
jgrandja commentedon Sep 1, 2020
@lizhongyue248 How are you testing the token request? Are you using a specific oauth2 client library or doing it manually, eg. curl?
FYI, the oauth2-integration sample works, which uses Spring Security 5.x client.
If you are testing manually, eg. curl, then you are likely not creating a valid token request. You really should be using an oauth2 client library instead.
jgrandja commentedon Sep 1, 2020
@louiemondot Thanks for the offer on looking into this. Let's hold off for now until we figure out if this is an issue or not.
lizhongyue248 commentedon Sep 1, 2020
@jgrandja Hi, I test api by
curl
, the oauth2-integration sample works, but my client is not a Spring Security application.Most of the time we need to adapt other oauth2 clients, so it is necessary to have the authorization server decode Base64
in request. or let me custom codeGenerator
Instead of letting the client decode.
And this:
jgrandja commentedon Sep 1, 2020
@lizhongyue248
You can use any oauth2 client library - you do not need to use Spring Security oauth2 client.
The authorization server should work with any oauth2 client library.
Regarding your comment
Mutual TLS client authentication has not been implemented as of yet so this won't work with current version. Only HTTP Basic is implemented.
I'm going to close this as the authorization server is implemented to spec and will (should) work with any oauth2 client library (as long as it is implemented to spec as well).
2 remaining items