This article is a mirror article of machine translation, please click here to jump to the original article.

View: 58862|Reply: 3

[Source] Learn about understanding JWT (JSON Web Tokens).

[Copy link]
Posted on 5/21/2018 3:56:52 PM | | | |
Introduction to JWT: JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way to securely transfer information between parties in JSON objects. This information can be verified and trusted through digital signatures. JWTs can be signed using secrets (using the HMAC algorithm) or using RSA's public/private key pairs.


Some scenarios where JSON Web Tokens are useful:

Identity Verification:This is the most common case of using JWTs. Once the user logs in, each subsequent request will contain a JWT that allows the user to access the routes, services, and resources allowed by that token. Single sign-on is a feature that is widely used today due to its low overhead and ability to be easily used across different domains.

Information exchange:JSON Web Tokens are a great way to securely transfer information between parties. Because JWTs can be signed - for example using public/private key pairs, it is possible to be sure that the sender is who they claim to be. In addition, since the signature is calculated using headers and payloads, you can also verify that the content has not been tampered with.


Official Website:The hyperlink login is visible.

Parse JWT information onlineThe hyperlink login is visible.



Analyze JWT parameters online  The hyperlink login is visible.

My understanding of JWT below is wrong, please give me some advice

First of all, this thing, it is not recommended for you to use it in the MVC website, you can use it in webapi, the positioning of this thing is API, not a session of the replacement website!

asp.net webapi usage tutorial:The hyperlink login is visible.I won't remake the wheel, looking at what this article is written is okay.

The composition of JWT

JWT is composed of three parts: Header, Payload, and Signature, with dot symbols in between to form the form of xx.yy.zz.


Note that for signed tokens, this information can be read by anyone, despite tampering protection. Do not place sensitive information in the valid content or header elements of the JWT unless encrypted.

For example:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

{
alg: "HS256",
typ: "JWT"
}.
{
sub: "1234567890",
name: "John Doe",
iat: 1516239022
}.
[signature]

In layman's terms, anyone can decrypt this token, but the authenticity of this information cannot be verified, only the server that generated this token can verify the authenticity, so do not store sensitive information in it.


There is a problem here, that is, if the user changes the password or the user is prohibited from logging in, how can JWT solve the validity of the token?

My own idea is to add a guid-like string in the Payload section, and then exist in the cache, when verifying the user's identity, not only verify the jwt, but also verify the Payload information in the jwt, we can control the validity by controlling the cache.







Previous:C# Open Source Framework (Reprint)
Next:You are using safe update mode and you tried to update a t
Posted on 8/22/2018 2:42:27 PM |
iss: jwt签发者
sub: jwt所面向的用户
aud: 接收jwt的一方
exp: jwt的过期时间,这个过期时间必须要大于签发时间
nbf: 定义在什么时间之前,该jwt都是不可用的.
iat: jwt的签发时间
jti: jwt的唯一身份标识,主要用来作为一次性token,从而回避重放攻击。


These are a set of predefined declarations that are not mandatory, but are recommended to provide a useful, interoperable set of declarations. Some of them are: iss (issuer), exp (expiration time), sub (theme), aud (audience), etc.

https://jwt.io/introduction/


 Landlord| Posted on 4/27/2021 10:59:48 AM |
header (after base64)
payload (after base64)
secret

base64 string is less than a multiple of 4, and you need to fill =
 Landlord| Posted on 1/21/2022 5:09:52 PM |
"iat" = > 1356999524, #token发布时间
"exp" = > 1556999524, #token过期时间
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com