Improve PyJWT resiliency support

This commit is contained in:
allegroai 2021-10-10 09:06:29 +03:00
parent 3b240b48c4
commit d747b2e93e
2 changed files with 10 additions and 2 deletions

View File

@ -70,10 +70,18 @@ class TokenManager(object):
@classmethod
def get_decoded_token(cls, token):
""" Get token expiration time. If not present, assume forever """
if hasattr(jwt, '__version__') and jwt.__version__[0] == '1':
return jwt.decode(
token,
verify=False,
algorithms=get_default_algorithms(),
)
return jwt.decode(
token,
options=dict(verify_signature=False),
algorithms=get_default_algorithms())
algorithms=get_default_algorithms(),
)
@classmethod
def _get_token_exp(cls, token):

View File

@ -11,7 +11,7 @@ Pillow>=4.1.1
psutil>=3.4.2
pyparsing>=2.0.3
python-dateutil>=2.6.1
pyjwt>=1.6.4,<3.0.0
pyjwt>=1.6.4,<=2.1.0
PyYAML>=3.12
requests>=2.20.0
six>=1.11.0