diff options
author | Javier Prieto <jprietove@gmail.com> | 2021-01-27 15:16:08 +0100 |
---|---|---|
committer | Javier Prieto <jprietove@gmail.com> | 2021-01-27 15:16:08 +0100 |
commit | e9367b03be14bfad70db36106a3de081b3f0ae82 (patch) | |
tree | 16ab59ea9db9cd188ca771b724f9993044f17fbe /websockify/token_plugins.py | |
parent | adc278657a9bb36514b15a80bb255f6878bbacbe (diff) | |
download | websockify-e9367b03be14bfad70db36106a3de081b3f0ae82.tar.gz |
Added exp claim for JWT token
Diffstat (limited to 'websockify/token_plugins.py')
-rw-r--r-- | websockify/token_plugins.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/websockify/token_plugins.py b/websockify/token_plugins.py index e03839a..80a9568 100644 --- a/websockify/token_plugins.py +++ b/websockify/token_plugins.py @@ -1,5 +1,6 @@ import os import sys +import time class BasePlugin(): def __init__(self, src): @@ -127,6 +128,12 @@ class JWTTokenApi(BasePlugin): token = jwt.JWT(key=key, jwt=token.claims) 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: |