-
-
Notifications
You must be signed in to change notification settings - Fork 801
Allow Authorization Code flow without a client_secret
#1092
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
Comments
Have you tried the same with I haven't looked at the blog post. Generally I test with Postman. Make sure your application has |
I've just tried with
It also triggered my debug breakpoint on I'll try updating postman, although I would still expect it to work with parameters manually set. |
Anything in the console? You can set debug-level logging in settings.py something like this:
|
Thanks, I set the debugging config and (through the log) noticed my client_secret was incorrect, it now works correctly through postman using Authentication tab. I've tried replicating the postman process manually but still get invalid_client error (using my old postman installation). Unsure what the difference between manual and postman process is but happy to close this issue. |
Not being able to rest without figuring out why this wasn't working. I delved into the request logs in Postman and compared them to my own. The difference was that client_secret was left out of my token request, but was used within the request via Postman. Sure enough, if I disable the parameter within my own request it fails again. I believe this is incorrect behaviour as Authorisation flow with PKCE shouldn't require the client_secret, this has effectively been replaced with the code_verifier. |
I do not believe that to he the case. Do you have an RFC document reference that says that? PKCE supplements, not replaces use of client_secret. However one can have a null client_secret now. Not sure if DOT implements that correctly, but that would be a different problem. This was the top hit on a google search and is on the Internet so it must be true ;-) |
Section [4.3] of RFC7636 (https://datatracker.ietf.org/doc/html/rfc7636#page-9) references Section 4.1.1 of RFC6749 which doesn't include the client_secret in the request. Interestingly I found a similar issue reported within Postman There does seem to be a bit of confusion about this online, I can't imagine sending the client secret would have any negative affects other than being unnecessary. |
Hey @R70YNS, Thanks for the research. I'm going to rename this issue to something about I suspect that this may not be implemented in DOT |
client_secret
No problem @n2ygk. I think the name change is better too, it more accurately describes the problem. I do think that those who can secure the For a workaround I will use a null value for the client_secret as you mentioned above. |
I'm curious to know if that will actually work. Looking forward to your report. |
Are you able to test with leaving the |
@n2ygk I can confirm it returns:
|
A PR implementing this would be gladly accepted! |
client_secret
client_secret
Hello @n2ygk |
Sure. No IRC. Just issue comments. |
Hey @n2ygk I did some looking around i think I've narrowed down the problem Original Code below:
By commenting out the elif part and the 'client_secret' assignment, Ive been able to get a token without problems.
Please let me know if there are other things i should be taking care of while addressing this issue. |
@bull500 commenting out the REQUIRED. The client secret. The client MAY omit the |
hey @n2ygk I've added a simple if-else check to the client secret assignment. Please let me know your thought and if this is good for PR
|
Add some test cases and should be good to go. |
Hello @n2ygk I've made a few changes and included test cases: In oauth2_validators.py used hasattr() to check object property exists
With respect to testcases, i edited the test_oauth2_validators.py file. Check is present if client_secret parameter is omitted when app is created with/without client secret. Code below:
|
Please put these changes in a PR so I can review and comment inline. FWIW, you can use 1c1
< client_secret = request.client_secret if hasattr(request, "client_secret") else ""
---
> client_secret = getattr(request.client_secret, "") |
I'm trying to achieve an Authorization Code with PKCE flow and public client for a Single Page web App (that can't keep a client_secret safe). I am using the latest release 2.4.0 but having the same issue described above.
@n2ygk do you (or anyone else) have any ideas as to what I might be doing wrong? |
After enabling PKCE with
PKCE_REQUIRED': True
I'm unable to retrieve an oauth response when submitting a request to/o/token/
. It provides a authentication code fine.This article has been used as reference: https://www.liip.ch/en/blog/authorization-code-with-pkce-on-django-using-django-oauth-toolkit
Here is the request (with client_id and code redacted)
The text was updated successfully, but these errors were encountered: