Merge branch 'new_branch' of https://github.com/jprietove/websockify
This commit is contained in:
commit
980237c9cd
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
class BasePlugin():
|
class BasePlugin():
|
||||||
def __init__(self, src):
|
def __init__(self, src):
|
||||||
|
@ -128,6 +129,18 @@ class JWTTokenApi(BasePlugin):
|
||||||
|
|
||||||
parsed = json.loads(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'])
|
return (parsed['host'], parsed['port'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed to parse token: %s" % str(e), file=sys.stderr)
|
print("Failed to parse token: %s" % str(e), file=sys.stderr)
|
||||||
|
|
Loading…
Reference in New Issue