-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
feat: Update PKCE_REQUIRED to true by default #1129
Conversation
12191d5
to
3ad3c45
Compare
This is a draft. After reviewing the compatibility section of RFC7636 Proof Key for Code Exchange by OAuth Public Clients. It should be backward compatible, so maybe it would be preferable to remove the PKCE setting from userspace and just set it to true in all cases. |
I actually looked at OAuthLib and it looks like this is a flag to require PKCE in a way that isn't officially specification compliant (it lacks backward compatibility). The questions that remain in my mind are
|
d11f831
to
42b375a
Compare
@dopry Have you run the tox tests locally to see that breaks them? I usually start testing with just a single py and dj version:
That still takes a while but then you can focus on the specific tests that fail and run them in your IDE if necessary to determine what happened. I'm guessing most of the failures are because the test case does not use PKCE. Regarding it being a breaking change: That's OK for release 2.0 which will have many breaking changes. I don't think it's necessary to put this through a deprecation cycle. |
BTW, If you change the test cases to use PKCE, also make a few failing tests where it's required as well as override the setting to have some successful tests where PKCE_REQUIRED=False. It looks like test_scopes is the only set of tests that fail.
So now I can focus just on those tests:
It appears to only be one error:
Probably because PKCE needs to be provided here: django-oauth-toolkit/tests/test_scopes.py Lines 89 to 96 in 2212144
I'm pretty sure you need to add these fields and implement a verifier. {
# ...
"code_challenge": CHALLENGE,
"code_challenge_method": METHOD
} There's already code that does this in test_authorization_code: django-oauth-toolkit/tests/test_authorization_code.py Lines 630 to 661 in 2212144
|
@n2ygk I wasn't asking about the testing. That's easy. My question is about how to handle the breaking change of defaulting PKCE_REQUIRED to true. Do we need a deprecation cycle, or is it cool to make the change and just document it. |
1b96fd3
to
9ffa362
Compare
@dopry Read all the way to the bottom where I said: Regarding it being a breaking change: That's OK for release 2.0 which will have many breaking changes. I don't think it's necessary to put this through a deprecation cycle. |
06e41d9
to
9841e1b
Compare
Codecov Report
@@ Coverage Diff @@
## master #1129 +/- ##
=======================================
Coverage 96.87% 96.87%
=======================================
Files 31 31
Lines 1790 1790
=======================================
Hits 1734 1734
Misses 56 56
Continue to review full report at Codecov.
|
b6a8f08
to
596a831
Compare
@n2ygk I missed that paragraph. I believe this should be ready to merge now. I'm assuming that PKCE_REQUIRED as a feature is already well covered by the existing suite of tests. I did add a test to verify that the default value is True. Let me know if there is anything you think I missed. side note: the test_models is failing for me locally, token clearing doesn't seem to be working properly in my local environment. 1) refresh token creation is failing because it seems to expect the model and not the id of the access token. |
BREAKING CHANGE: set to False to maintain legacy behavior
8df4e2d
to
a2663ca
Compare
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a minor change to CHANGELOG.md please
Assuming PKCE is properly implemented this change should be backwards
compatible with clients that do not support PKCE, see:
https://datatracker.ietf.org/doc/html/rfc7636#section-5
applies to #1122
Description of the Change
Checklist
CHANGELOG.md
updated (only for user relevant changes)AUTHORS