29 lines
580 B
Python
Executable File
29 lines
580 B
Python
Executable File
import time
|
|
import connexion
|
|
import six
|
|
from werkzeug.exceptions import Unauthorized
|
|
from jose import JWTError, jwt
|
|
import os
|
|
|
|
JWT_SECRET = os.environ['JWT_SECRET']
|
|
|
|
|
|
|
|
def decode_token(token):
|
|
try:
|
|
return jwt.decode(token, JWT_SECRET)
|
|
except JWTError as e:
|
|
six.raise_from(Unauthorized, e)
|
|
|
|
|
|
def get_secret(user, token_info) -> str:
|
|
return '''
|
|
You are user_id {user} and the secret is 'wbevuec'.
|
|
Decoded token claims: {token_info}.
|
|
'''.format(user=user, token_info=token_info)
|
|
|
|
|
|
def _current_timestamp() -> int:
|
|
return int(time.time())
|
|
|