Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit b18747d

Browse files
committed
Fixes #103
- Require PyJWT v1.1.0 or greater. - Use decode options instead of verify_expiration
1 parent deea4ad commit b18747d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

rest_framework_jwt/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ def jwt_encode_handler(payload):
4747

4848

4949
def jwt_decode_handler(token):
50+
options = {
51+
'verify_exp': api_settings.JWT_VERIFY_EXPIRATION,
52+
}
53+
5054
return jwt.decode(
5155
token,
5256
api_settings.JWT_SECRET_KEY,
5357
api_settings.JWT_VERIFY,
54-
verify_expiration=api_settings.JWT_VERIFY_EXPIRATION,
58+
options=options,
5559
leeway=api_settings.JWT_LEEWAY,
5660
audience=api_settings.JWT_AUDIENCE,
5761
issuer=api_settings.JWT_ISSUER,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
author_email = '[email protected]'
1919
license = 'MIT'
2020
install_requires = [
21-
'PyJWT>=1.0.0,<2.0.0',
21+
'PyJWT>=1.1.0,<2.0.0',
2222
]
2323

2424

tests/test_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ def test_jwt_response_payload(self):
5757

5858
self.assertEqual(response_data, dict(token=token))
5959

60+
def test_jwt_decode_verify_exp(self):
61+
api_settings.JWT_VERIFY_EXPIRATION = False
62+
63+
payload = utils.jwt_payload_handler(self.user)
64+
payload['exp'] = 1
65+
token = utils.jwt_encode_handler(payload)
66+
utils.jwt_decode_handler(token)
67+
68+
api_settings.JWT_VERIFY_EXPIRATION = True
69+
6070

6171
class TestAudience(TestCase):
6272
def setUp(self):

0 commit comments

Comments
 (0)