Added exp claim for JWT token

This commit is contained in:
Javier Prieto 2021-01-27 15:16:08 +01:00
parent adc278657a
commit e9367b03be
1 changed files with 7 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import os
import sys
import time
class BasePlugin():
def __init__(self, src):
@ -128,6 +129,12 @@ class JWTTokenApi(BasePlugin):
parsed = json.loads(token.claims)
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:
print("Failed to parse token: %s" % str(e), file=sys.stderr)