This commit is contained in:
Pierre Ossman 2021-01-29 13:10:49 +01:00
commit 980237c9cd
1 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import os
import sys
import time
class BasePlugin():
def __init__(self, src):
@ -127,6 +128,18 @@ class JWTTokenApi(BasePlugin):
token = jwt.JWT(key=key, jwt=token.claims)
parsed = json.loads(token.claims)
if 'nbf' in parsed:
# Not Before is present, so we need to check it
if time.time() < parsed['nbf']:
print('Token can not be used yet!', file=sys.stderr)
return None
if 'exp' in parsed:
# Expiration time is present, so we need to check it
if time.time() > parsed['exp']:
print('Token has expired!', file=sys.stderr)
return None
return (parsed['host'], parsed['port'])
except Exception as e: