From e9367b03be14bfad70db36106a3de081b3f0ae82 Mon Sep 17 00:00:00 2001 From: Javier Prieto Date: Wed, 27 Jan 2021 15:16:08 +0100 Subject: [PATCH] Added exp claim for JWT token --- websockify/token_plugins.py | 7 +++++++ 1 file changed, 7 insertions(+) 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: