def wrapper(self, *args, **kwargs): token = request.headers.get('X-API-KEY', '') if not token: return "", 401, { "WWW-Authenticate": "Basic realm='Authentication required'" } try: uuid = jwt.decode(token, app.config['SECRET_KEY'])['user_id'] except (KeyError, jwt.ExpiredSignatureError): return "", 401, { "WWW-Authenticate": "Basic realm='Authentication required'" } user = User.find_user_by_uuid(uuid) if not user: return "", 401, { "WWW-Authenticate": "Basic realm='Authentication required'" } return func(self, *args, **kwargs)
def wrapper(self, *args, **kwargs): token = request.headers.get('X-API-KEY', '') if not token: return '', 401, { 'WWW-Authenticate': 'Basic realm="Authenticate required"' } try: uuid = jwt.decode(token, app.config['SECRET_KEY'], algorithms=["HS256"])['user_id'] except (KeyError, jwt.ExpiredSignatureError): return '', 401, { 'WWW-Authenticate': 'Basic realm="Authenticate required"' } user = User.find_user_by_uuid(uuid) if not user: return '', 401, { 'WWW-Authenticate': 'Basic realm="Authenticate required"' } return func(self, *args, **kwargs)