-
Notifications
You must be signed in to change notification settings - Fork 670
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
Fix: Disable refresh token for inactive user. #814
Fix: Disable refresh token for inactive user. #814
Conversation
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.
@ajay09
Actually, I suggest using Django signals to automatically update the BlacklistedToken list when user accounts are disabled. Once a user account is disabled, we'll add all of their tokens to the blacklist to prevent their future use. Since self.check_blacklist
is available by default, I think this would be better than performing an additional query every time.
@wissam-al-kahwaji |
@ajay09 |
@wissam-al-kahwaji |
@ajay09 |
@wissam-al-kahwaji Please let me know if there is a way of getting the associated token. |
@ajay09 |
I don't think we should modify the blacklist table to store whether use is active/inactive, preserving Separation of concerns. |
It will be responsible for clarifying whether the user is completely blacklisted or whether it is just the token |
Hmm. I don't think this is the correct fix. Instead the refresh serializers should be calling api_settings.USER_AUTHENTICATION_RULE in their validate methods, like TokenObtainSerializer already does. The implementation you have in this PR requires that blacklisting (an optional feature) is enabled. Also JWTAuthentication should be using USER_AUTHENTICATION_RULE instead of only checking User.is_active (to gain access to any custom rules). Also please add a test to verify the fix. |
@vainu-arto Thanks. |
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.
LGTM.
@wissam-al-kahwaji |
@wissam-al-kahwaji Excuse me, but can we move ahead with 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.
Nothing else, everything looks good, Thanks for your contribution
Can we get this merged? |
@timmyomahony |
Uhmm.. can i take a look at this? |
Yes please! |
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.
Following the conversation, the patches made and the review comments, this looks good to me.
let's push this out there :) |
I don't believe it, folks. |
Please, make a PyPI release ASAP. |
Issue Description:
A refresh token generated for a previously active user was allowed to issue new access token although the user is inactive.
Fix:
Added a check to verify if the user claim in refresh token corresponds to an active user.
Related issues