gpt4 book ai didi

java - JSON Web Token 如何验证用户的身份验证?

转载 作者:行者123 更新时间:2023-12-02 11:50:09 27 4
gpt4 key购买 nike

JSON Web token 如何在身份验证时验证用户? JWT 是否存储用户数据?

如果是这样,我如何获取已完成身份验证的用户列表?

最佳答案

在基于 token 的身份验证上下文中, token 是识别用户的一段数据,充当执行身份验证的凭据。

<小时/>

JWT是一个自包含的 token ,包含三个部分:

  • 标题
  • 有效负载
  • 签名

有效负载包含一组声明,您可以使用它来存储任何任意数据。

可以通过使用私钥验证服务器端生成的签名(使用编码为 Base64 的 header 和有效负载)来检查 token 的完整性。 JWT 允许您执行无状态身份验证,也就是说,除了用于签署 token 的 key 之外,您不需要在服务器端存储任何内容。

<小时/>

sub是存储作为 JWT 主体的主体(为其颁发 token 的用户)的标准有效负载声明:

4.1.2. "sub" (Subject) Claim

The sub (subject) claim identifies the principal that is thesubject of the JWT. The claims in a JWT are normally statementsabout the subject. The subject value MUST either be scoped to belocally unique in the context of the issuer or be globally unique.The processing of this claim is generally application specific. Thesub value is a case-sensitive string containing a StringOrURIvalue. Use of this claim is OPTIONAL.

关于java - JSON Web Token 如何验证用户的身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47940131/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com