对于同一个用户,用户请求新的token后,JWT的签名有何不同?

For the same user, how is JWT's signature different after the user requests a new token?

我对服务器使用 JWT 验证用户的方式的理解是,服务器使用自己的密钥对 JWT 的有效负载部分进行哈希处理,然后将结果与 JWT 的签名部分进行比较。如果两者匹配,则用户提出的请求有效。

但是,我无法了解人们如何在用户刷新令牌时生成不同的 JWT。对我来说,为了确保在刷新令牌时生成唯一的 JWT,需要更改有效负载,比如添加到期日期 + 用户 ID。但是,大多数在线资源都没有提到在旧 JWT 过期时生成新的唯一 JWT 的过程。我在这里错过了什么吗?当旧的 JWT 过期时,人们不会生成唯一的 JWT,而是简单地在服务器端延长 JWT 的生命周期吗?

My understanding on the way server verifies a user using JWT is that server hashes the payload part of JWT with its own secret key and then compares the result against the signature part of JWT. If the two matches, then the request made by the user is valid.

是的,是的。

However, I am not able to find out how people generate different JWT when a user refreshes the token.

签名对于不同的有效载荷会有所不同,即使变化很小。通常包含日期声明,例如 expiss,使令牌始终不同。

Do people not generate unique JWT when the old one is expired and instead, simply extends the lifetime of JWT on server side?

不,因为它需要维护会话并且您失去了使用 JWT 的优势。刷新时,会发出一个新的token。