我使用django-rest-framework-simplejwt进行身份验证。在每个请求中,我需要检查令牌是否某个变量有效(如果create_time < last change password,我将拒绝连接)。在django中最好的方法是什么?
我认为最好的解决方案是创建带有验证的新类,但是我不知道它应该包括什么?我有3个候选人
'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule',
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
'DEFAULT_AUTHENTICATION_CLASSES':('rest_framework_simplejwt.authentication.JWTAuthentication',)发布于 2021-07-29 05:49:28
我找到的答案是:
‘’DEFAULT_AUTHENTICATION_class‘:(’my_class‘,'rest_framework_simplejwt.authentication.JWTAuthentication',)
类my_class(JWTAuthentication):定义身份验证(self,request):验证检查
https://stackoverflow.com/questions/68552188
复制相似问题