手动JWT令牌认证是否正常?

时间:2018-04-20 12:18:27

标签: python flask jwt

我使用flask构建了一个graphql web服务器。现在我尝试使用jwt进行用户身份验证。所以我为登录和注册创建了2个端点。用户登录后,他获得了访问令牌。但我只需要保护一个模式(用户模式),这样我就无法保护整个graphql端点。我所做的是从请求标头中获取令牌并对其进行解码以获取用户信息。它工作得很好,但我担心这可能是安全漏洞。是否有人可以从架构中轻松访问访问令牌?这是我的架构代码

class Query(graphene.ObjectType):
    node = relay.Node.Field()
    user = graphene.Field(User)
    def resolve_user(self, info):
         query = User.get_query(info)
         token = info.context.headers.get("AUTHORIZATION")
         token_type = decode_token(token)["type"]
         email = None
         if token_type == "access":
               email = decode_token(token)["identity"]
         return query.filter_by(email=email).first()

提前谢谢

0 个答案:

没有答案
相关问题