Skip to content

Commit 455a063

Browse files
committed
Sem-ver: api-break Require PyJWT >= 2.11.0
Signed-off-by: David Black <dblack@atlassian.com>
1 parent a07b321 commit 455a063

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

atlassian_jwt_auth/signer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import jwt
77
from cryptography.hazmat.backends import default_backend
88
from cryptography.hazmat.primitives import serialization
9+
from jwt.types import Options
910

1011
from atlassian_jwt_auth import algorithms, key
1112
from atlassian_jwt_auth.key import BasePrivateKeyRetriever, KeyIdentifier
@@ -116,8 +117,9 @@ def can_reuse_token(self, existing_token, claims) -> bool:
116117
"""
117118
if existing_token is None:
118119
return False
120+
119121
existing_claims = jwt.decode(
120-
existing_token, options={"verify_signature": False}
122+
existing_token, options=Options(verify_signature=False)
121123
)
122124
existing_lifetime = int(existing_claims["exp"]) - int(existing_claims["iat"])
123125
this_lifetime = (claims["exp"] - claims["iat"]).total_seconds()

atlassian_jwt_auth/verifier.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
1111
from jwt import PyJWK
1212
from jwt.exceptions import InvalidAlgorithmError
13+
from jwt.types import Options
1314

1415
from atlassian_jwt_auth import KeyIdentifier, algorithms, exceptions, key
1516
from atlassian_jwt_auth.key import BasePublicKeyRetriever
@@ -96,12 +97,12 @@ def _decode_jwt(
9697
leeway: int = 0,
9798
) -> Dict[Any, Any]:
9899
"""Decode JWT and check if it's valid"""
99-
options = {
100-
"verify_signature": True,
101-
"require": ["exp", "iat"],
102-
"require_exp": True,
103-
"require_iat": True,
104-
}
100+
options: Options = Options(
101+
verify_signature=True,
102+
require=["exp", "iat"],
103+
verify_exp=True,
104+
verify_iat=True,
105+
)
105106

106107
claims = jwt.decode(
107108
a_jwt,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PyJWT>=2.4.0,<3.0.0
1+
PyJWT>=2.11.0,<3.0.0
22
PyJWT[crypto]>=2.4.0,<3.0.0
33
requests>=2.8.1,<3.0.0
44
CacheControl

0 commit comments

Comments
 (0)