middlewares.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:IntegraTI-API 作者: discentes-imd 项目源码 文件源码
def verify_token():
    """
    Verify if the token is valid, not expired and not blacklisted
    """
    if 'Authorization' in request.headers:
        if request.headers['Authorization'] in cache.blacklisted_tokens:
            abort(403, 'Error: invalid token')
        try:
            payload = jwt.decode(request.headers['Authorization'], config.SECRET_KEY)
            g.current_user = payload['id_user']
        except jwt.ExpiredSignatureError:
            abort(403, 'Error: token expired')
        except jwt.DecodeError:
            abort(403, 'Error: invalid token')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号