Files
Hui-s-notebook/logseq-java/pages/JWT.md
2024-02-02 00:12:49 +08:00

20 lines
747 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- [[Cookie]]+ [[Session]]
- 保存用户登录状态
- 缺陷
- Cookie不安全信息以明文存储
- Session占用服务器资源横向集群拓展麻烦
- Cookie为浏览器的技术存储空间有限很多前端不再依赖浏览器
- JSON Web Token
- ![image.png](../assets/image_1658140156367_0.png)
- Header
- 声明令牌由JWT技术产生加密技术HS256
- Payload
- 后端需要传输的数据
- Signature
- 说明由谁颁发
- 无法破解
- 执行原理
- 登录 --> Web服务器产生令牌 --> 存Redis有效期30min
- 前端存储在localStorage里还是Cookie或其他数据库与后端无关前端发请求时需要带上Token
- [[axios]]全局拦截器
- [[SpringBoot]]配置拦截器