[英]return token after registration with django-rest-framework-simplejwt
[英]django-rest-framework-simplejwt validate parameter inside the token
我使用 django-rest-framework-simplejwt 進行身份驗證。 在每個請求中,如果某個變量有效,我需要檢查令牌(如果 create_time < 上次更改密碼,我將拒絕連接)。 在 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',)
我找到的答案:
'DEFAULT_AUTHENTICATION_CLASSES':('my_class','rest_framework_simplejwt.authentication.JWTAuthentication',)
class my_class(JWTAuthentication): def authentication(self, request): 驗證檢查
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.