问题重现

当查看DRF 文档时发现DRF内置的token是存储在数据库里,这和我在网上搜索资料时认识的token-based authentication有出入。

from rest_framework.authtoken.models import Token # 有Token这个model

原因

其实网上大多数的token是json web token,是和DRF自带的token不同的。JWT只存储在客户端。具体google:double submit cookie vs synchronizer token

引用DRF文档:

JSON Web Token is a fairly new standard which can be used for token-based authentication. Unlike the built-in TokenAuthentication scheme, JWT Authentication doesn't need to use a database to validate a token. A package for JWT authentication is djangorestframework-simplejwt which provides some features as well as a pluggable token blacklist app.

参考

  1. https://www.django-rest-framework.org/api-guide/authentication/#json-web-token-authentication
  2. https://stackoverflow.com/questions/57442082/why-django-rest-framework-stores-token-in-database?noredirect=1#comment101361728_57442082
  3. https://stackoverflow.com/questions/29440014/should-i-use-jwt-or-basic-token-authentication-in-django-rest-framework
  4. https://stackoverflow.com/questions/27578726/appropriate-choice-of-authentication-class-for-python-rest-api-used-by-web-app
  5. https://stackoverflow.com/questions/31600497/django-drf-token-based-authentication-vs-json-web-token
  6. https://stackoverflow.com/questions/14567586/token-authentication-for-restful-api-should-the-token-be-periodically-changed
  7. https://stackoverflow.com/questions/43452896/authentication-jwt-usage-vs-session

最新文章

  1. Linux之head、tail、grep、cut等命令详解
  2. 《java JDK7 学习笔记》课后练习题3
  3. UVa1589 象棋
  4. python开发vim插件
  5. PowerDesigner概念模型的Notation设置
  6. web服务器分析与设计(一)
  7. 开启g++ 编辑器 c++11特性
  8. JS代码获取当前日期时支持IE,不兼容FF和chrome,解决这个问题,我们需要把获取时间的getYear()函数换成getFullYear()
  9. iOS RGB颜色封装
  10. NOI2007 生成树计数
  11. SVN无法修改以前提交日志的办法
  12. Linux/UNIX流程关系
  13. ThoughtWorks开发持续集成及部署利器:Go
  14. ubuntu 1604安装docker-ce 记录
  15. CLion之C++框架篇-优化开源框架,引入curl,实现get方式获取资源(四)
  16. 使用entitiy
  17. SpringMVC(四):什么是HandlerAdapter
  18. NumsCount
  19. 非root用户执行java进程报错:fork: retry:资源暂时不可用
  20. LeetCode: Binary Search Tree Iterator 解题报告

热门文章

  1. MATLAB用“fitgmdist”函数拟合高斯混合模型(一维数据)
  2. Java对MongoDB进行分组操作并统计各个分组的数量
  3. ASP.NET Process Model之二:ASP.NET Http Runtime Pipeline - Part II
  4. Controller 和 Action -1
  5. Django | mysql修改个别表后save()报错
  6. maven镜像地址以及maven仓库
  7. 为什么hashmap的容量永远要是2的次方
  8. docker installation and usage
  9. 嵌入式Linux学习---进程(1)
  10. [HTML] websocket的模拟日志监控界面