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

Check expiration of token #218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Check expiration of token #218

wants to merge 2 commits into from

Conversation

paulw11
Copy link

@paulw11 paulw11 commented Apr 6, 2020

The current code doesn't check to see if the supplied access token is expired.
This adds a check for the exp field of the JWT

@@ -90,6 +91,11 @@ def validate_token_request(self, request):

try:
user = backend.do_auth(access_token=request.token)
user_data = backend.user_data(access_token=request.token)
exp = user_data['exp']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the value exp holds?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exp is the expiration date of the token

rest_framework_social_oauth2/oauth2_grants.py Outdated Show resolved Hide resolved
@@ -90,6 +91,11 @@ def validate_token_request(self, request):

try:
user = backend.do_auth(access_token=request.token)
user_data = backend.user_data(access_token=request.token)
exp = user_data['exp']
if not exp and exp <= datetime.now():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The not operator having higher precedence makes this always evaluate to False whenever exp evaluates to True. Can you please explain the desired operation here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants