28 lines
637 B
Python
28 lines
637 B
Python
__author__ = "Florian Kaiser"
|
|
__copyright__ = "Copyright 2022, Project Aktienbot"
|
|
__credits__ = ["Florian Kaiser", "Florian Kellermann", "Linus Eickhof", "Kevin Pauer"]
|
|
__license__ = "GPL 3.0"
|
|
__version__ = "1.0.0"
|
|
|
|
from flask import current_app
|
|
|
|
import jwt
|
|
from apiflask import HTTPTokenAuth
|
|
|
|
auth = HTTPTokenAuth()
|
|
|
|
|
|
@auth.verify_token
|
|
def verify_token(token):
|
|
if token is None:
|
|
return False
|
|
|
|
if ':' in token: # Bot token
|
|
token = token.split(":")[0]
|
|
|
|
try:
|
|
jwt.decode(token, current_app.config['SECRET_KEY'], algorithms=["HS256"])
|
|
return True
|
|
except jwt.PyJWTError:
|
|
return False
|