0

我使用 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',)
4

1 回答 1

0

我找到的答案:

'DEFAULT_AUTHENTICATION_CLASSES':('my_class','rest_framework_simplejwt.authentication.JWTAuthentication',)

class my_class(JWTAuthentication): def authentication(self, request): 验证检查

于 2021-07-28T21:49:28.147 回答