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

Bugfix: Ensure blacklist expires_at is set in a fully UTC context #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jgruppuso
Copy link

This was found in a context where UTC was not the Django timezone, but rather Asia/Tokyo. I have added a test which replicates the issue.

Before:

(Pdb) iat
1685329261
(Pdb) expires_at_unix_time
1685331061.0
(Pdb) datetime.utcfromtimestamp(iat)
datetime.datetime(2023, 5, 29, 3, 1, 1)
(Pdb) datetime.utcfromtimestamp(expires_at_unix_time)
datetime.datetime(2023, 5, 29, 3, 31, 1)
(Pdb) make_aware(datetime.utcfromtimestamp(expires_at_unix_time))
datetime.datetime(2023, 5, 29, 3, 31, 1, tzinfo=zoneinfo.ZoneInfo(key='Asia/Tokyo'))

iat (UTC)
expires_at_unix_time = iat + 30mins (UTC)
expires_at = iat + 30mins (Asia/Tokyo) → this means the token is created already expired!

After:

(Pdb) iat
1685335304
(Pdb) expires_at_unix_time
1685940104.0
(Pdb) datetime.datetime.utcfromtimestamp(iat)
datetime.datetime(2023, 5, 29, 4, 41, 44)
(Pdb) datetime.datetime.utcfromtimestamp(expires_at_unix_time)
datetime.datetime(2023, 5, 29, 5, 11, 44)
(Pdb) make_aware(datetime.datetime.utcfromtimestamp(expires_at_unix_time),timezone=datetime.timezone.utc)
datetime.datetime(2023, 5, 29, 5, 11, 44, tzinfo=datetime.timezone.utc)

iat (UTC)
expires_at_unix_time = iat + 30mins (UTC)
expires_at = iat + 30mins (UTC)

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.

1 participant