Skip to content

Commit acacec8

Browse files
authored
fix: Do not copy iat claim from refresh token (#888)
* fix: Do not copy `iat` claim from refresh token * fix test by freezing time
1 parent 1ac00c6 commit acacec8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

rest_framework_simplejwt/tokens.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ class RefreshToken(BlacklistMixin["RefreshToken"], Token):
386386
# we wouldn't want to copy either one.
387387
api_settings.JTI_CLAIM,
388388
"jti",
389+
"iat",
389390
)
390391
access_token_class = AccessToken
391392

tests/test_tokens.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.contrib.auth import get_user_model
66
from django.test import TestCase
7+
from freezegun import freeze_time
78
from jose import jwt
89

910
from rest_framework_simplejwt.exceptions import (
@@ -434,10 +435,13 @@ def test_init(self):
434435

435436
def test_access_token(self):
436437
# Should create an access token from a refresh token
437-
refresh = RefreshToken()
438-
refresh["test_claim"] = "arst"
438+
with freeze_time("2025-01-01"):
439+
refresh = RefreshToken()
440+
refresh["test_claim"] = "arst"
439441

440-
access = refresh.access_token
442+
with freeze_time("2025-01-02"):
443+
# Ensure iat is different
444+
access = refresh.access_token
441445

442446
self.assertIsInstance(access, AccessToken)
443447
self.assertEqual(access[api_settings.TOKEN_TYPE_CLAIM], "access")

0 commit comments

Comments
 (0)