当前位置:网站首页>一文带你搞懂 JWT 常见概念 & 优缺点
一文带你搞懂 JWT 常见概念 & 优缺点
2022-06-25 15:38:00 【JavaGuide】
本文原发于 JWT 身份认证优缺点分析 。
在 JWT 基本概念详解这篇文章中,我介绍了:
- 什么是 JWT?
- JWT 由哪些部分组成?
- 如何基于 JWT 进行身份验证?
- JWT 如何防止 Token 被篡改?
- 如何加强 JWT 的安全性?
这篇文章,我们一起探讨一下 JWT 身份认证的优缺点以及常见问题的解决办法。
JWT 的优势
相比于 Session 认证的方式来说,使用 JWT 进行身份认证主要有下面 4 个优势。
无状态
JWT 自身包含了身份验证所需要的所有信息,因此,我们的服务器不需要存储 Session 信息。这显然增加了系统的可用性和伸缩性,大大减轻了服务端的压力。
不过,也正是由于 JWT 的无状态,也导致了它最大的缺点:不可控!
就比如说,我们想要在 JWT 有效期内废弃一个 JWT 或者更改它的权限的话,并不会立即生效,通常需要等到有效期过后才可以。再比如说,当用户 Logout 的话,JWT 也还有效。除非,我们在后端增加额外的处理逻辑比如将失效的 JWT 存储起来,后端先验证 JWT 是否有效再进行
边栏推荐
- 免费送书啦!火遍全网的AI给老照片上色,这里有一份详细教程!
- Golang regular regexp package uses -05- extend expand(), cut split() according to the rule
- JS add custom attributes to elements
- Sleep formula: how to cure bad sleep?
- Ten routing strategies for distributed task scheduling platform XXL job
- What is session? How is it different from cookies?
- Finally, we can figure out whether the binding event in the tag is bracketed or not
- MT60B1G16HC-48B:A美光内存颗粒FBGA代码D8BNK[通俗易懂]
- 通俗讲跨域
- 剑指 Offer 04. 二维数组中的查找
猜你喜欢
Client development (electron) system level API usage 2
Golang open source streaming media audio and video network transmission service -lal

Don't underestimate the integral mall, its role can be great!
Consumer and producer cases of inter thread synchronization (condition variable)
How to debug grpc by postman
Mixed density network (MDN) for multiple regression explanation and code example

免费送书啦!火遍全网的AI给老照片上色,这里有一份详细教程!

Sword finger offer 03 Duplicate number in array

Rapport de la main - d'oeuvre du Conseil de développement de l'aecg air32f103cbt6

Sword finger offer II 091 Paint the house
随机推荐
Don't underestimate the integral mall, its role can be great!
商城风格也可以很多变,DIY了解一下!
加载本地cifar10 数据集
[issue 24] one year experience of golang to develop futu
元宇宙系统的概念解析
面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
通俗讲跨域
f_read 函数[通俗易懂]
The release of autok3s v0.5.0 continues to be simple and friendly
How GC determines whether an object can be recycled
转换Cifar10数据集
剑指 Offer II 091. 粉刷房子
Popular cross domain
基于深度Q学习的雅达利打砖块游戏博弈
MT60B1G16HC-48B:A美光内存颗粒FBGA代码D8BNK[通俗易懂]
Differences and solutions of redis cache avalanche, cache penetration and cache breakdown
MySQL modifier l'instruction de champ
AspNetCore&云效Flow持续集成
Client development (electron) data store
深度学习 pytorch cifar10数据集训练「建议收藏」