-
Notifications
You must be signed in to change notification settings - Fork 447
Bug: Valid Refresh Tokens despite user changing password #950
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
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #950 +/- ##
========================================
Coverage 96.00% 96.01%
========================================
Files 96 96
Lines 5307 5319 +12
========================================
+ Hits 5095 5107 +12
Misses 212 212
|
@devkapilbansal @isabelcosta As far as I understand, I've to add a test when the password is changed, and we are using the same (old) refresh token (a test where we go inside the if condition). Am I correct? Is there anything else needed? Thanks in advance :) |
Yes @tichnas you have too. |
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.
Going in the right direction 👍
6ba9c63
to
7c18a81
Compare
@isabelcosta @devkapilbansal Please review. Thanks :) |
@tichnas don't use hard coded status codes in test. You have used 401(hard coded). Replace it by using it from HTTP_STATUS as done in API files |
@devkapilbansal It's like this in all test files. Should I change them all or just this one? |
Change for the tests you added. It would be better to open an issue for them |
7c18a81
to
9872c7e
Compare
Thanks for the suggestion @devkapilbansal. I've updated the test case and have also created an issue for all other test cases. |
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.
Thanks @tichnas Tested locally and it works
The changes made in this PR were tested locally. Following are the results:
-
Code review - Done
-
All possible responses (positive and negative tests) were tested as below:
- Test1 Description Refresh Token Validation after Password Change
Screenshot/gif:
Refresh Token Valid before Password Change
Refresh Token invalid after Password Change
_Expected Result_: Token should be invalid after password change
_Actual Result_: Same as expected
- Status of PR Changed to: Ready to Merge.
@vj-codes @isabelcosta Kindly review this PR |
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.
Thank you for your contibution @tichnas 🎉
Adding label ready to merge since testing is done above |
@tichnas @devkapilbansal and @vj-codes I put the "on Hold" label because I am not sure this is a secure solution, to include the password hash in the token. This is because a jwt token, when decoded can reveal the content of the identity. You can see here https://jwt.io/ the composition of a token. I would like to have other opinions on this, perhaps we could reach out to Zulip community and ask. I'll post on Zulip and look more into this. cc @ramitsawhney27 @m-murad @SanketDG in case you have any idea about this 🙏 |
uh oh! 😅 I see it now. This was not what I meant. The content of the token need not be changed. What needs to be changed is the refresh signing key. Thanks @isabelcosta for catching this. |
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.
The contents of the token do not need to be modified. Just append the users password hash while you sign the refresh token that is all.
Hi @isabelcosta, @tichnas, @devkapilbansal, @epicadk, and @vj-codes. Just thought I might share my two cents here 😉. Apologies if it doesn't make sense though, still a newbie here with python and jwt 🤣🤣🤣. |
I will close this PR due to inactivity. Thank you @tichnas for your contribution 🙌 |
Description
Password is added along with id as the identity for refresh token to make it invalid on password change.
Fixes #903
Type of Change:
How Has This Been Tested?
Ran
python -m unittest discover tests
which gave OK resultChecklist:
Code/Quality Assurance Only