Skip to content
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

/oauth2/token endpoint parameter validate. #102

Closed
lizhongyue248 opened this issue Aug 23, 2020 · 7 comments
Closed

/oauth2/token endpoint parameter validate. #102

lizhongyue248 opened this issue Aug 23, 2020 · 7 comments
Assignees
Labels
status: invalid An issue that we don't feel is valid

Comments

@lizhongyue248
Copy link

lizhongyue248 commented Aug 23, 2020

Describe the bug
/oauth2/token endpoint parameter code url decode.

To Reproduce

  1. I get code from /oauth2/authorize endpoint redirect url paramters. The code is Iz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY%3D
  2. And I use the code post /oauth2/token, it will give me a error
{
    "error": "invalid_grant"
}
  1. I try to use url decode Iz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY%3D, the right code is Iz5jWzV00fcxhIAomMff_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.

@lizhongyue248 lizhongyue248 added the type: bug A general bug label Aug 23, 2020
@louiemondot
Copy link

I like to have a go at this one if that's possible.

@lizhongyue248 lizhongyue248 changed the title /oauth2/token endpoint parameter code url decode. /oauth2/token endpoint parameter validate. Aug 25, 2020
@lizhongyue248
Copy link
Author

lizhongyue248 commented Aug 25, 2020

Describe the bug

I get a error when access /oauth2/token with client_id.

To Reproduce

  1. I get code from /oauth2/authorize endpoint redirect url paramters. The code is Iz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY%3D
  2. And I use decode code and post to /oauth2/token with client_id, I get a error:
{
    "error": "invalid_client"
}
  1. I remove this paramter, it work.

Debug the code:

When I post with client_id, the getPrincipal() is String

When I post without client_id, the the getPrincipal() is OAuth2ClientAuthenticationToken and isAuthenticated is false.

Expect havior

Please see RFC-6749 section-4.1.3.

REQUIRED, if the client is not authenticating with the authorization server as described in Section 3.2.1.

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
Copy link

Describe the bug

I get a error when access /oauth2/token with client_id.

To Reproduce

1. I get code from /oauth2/authorize endpoint redirect url paramters. The code is Iz5jWzV00fcxhIAomMff_COjDsU8o_ifiLrdZK9U4wY%3D

2. And I use decode code and post to `/oauth2/token` with `client_id`, I get a error:
{
    "error": "invalid_client"
}
1. I remove this paramter, it work.

Debug the code:

When I post with client_id, the getPrincipal() is String

When I post without client_id, the the getPrincipal() is OAuth2ClientAuthenticationToken and isAuthenticated is false.

Expect havior

Please see RFC-6749 section-4.1.3.

REQUIRED, if the client is not authenticating with the authorization server as described in Section 3.2.1.

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.

Don't carry parameters clientId Inside the header,ohhhhhhhh

@jgrandja
Copy link
Collaborator

jgrandja commented 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 jgrandja self-assigned this Sep 1, 2020
@jgrandja jgrandja added status: waiting-for-feedback We need additional information before we can continue and removed type: bug A general bug labels Sep 1, 2020
@jgrandja
Copy link
Collaborator

jgrandja commented 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
Copy link
Author

lizhongyue248 commented 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:

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.

@jgrandja
Copy link
Collaborator

jgrandja commented Sep 1, 2020

@lizhongyue248

my client is not a Spring Security application

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

The request header has Client Certificate

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).

@jgrandja jgrandja closed this as completed Sep 1, 2020
@jgrandja jgrandja added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 1, 2020
vincent-hsin added a commit to vincent-hsin/spring-authorization-server that referenced this issue Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants