About JWT:
I have used jwt authentication in the Java project spring boot framework before, but I haven't used it in C# yet, and this article implements mailbox validation based on jwt. The flow chart is as follows:
In your project, use nuget to install the JWT plugin:
Encapsulates the JwtHelper help class as follows:
Try using the console call, we will put the expiration date of the jwtThe default setting is 15 minutes, the console code is as follows:
You can see that the token can get the value normally,token1 has expired, causing an exception to be thrownAs follows:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Iml0c3ZzZUBpdHN2c2UuY29tIiwiZXhwIjoxNjA0ODIxMDQxLjB9.JG2pYtJxXTXBDs7Qtk9QBd5sR4BynxkirQ355sIu5Kg
itsvse@itsvse.com
JWT.Exceptions.TokenExpiredException: Token has expired. At JWT. JwtValidator.Validate(String decodedPayload, String signature, String[] decodedSignatures) At JWT. JwtDecoder.Validate(JwtParts jwt, Byte[][] keys) At JWT. JwtDecoder.Decode(JwtParts jwt, Byte[] key, Boolean verify) At JWT. JwtDecoder.DecodeToObject[T](JwtParts jwt, Byte[] key, Boolean verify) At JWT. JwtDecoderExtensions.DecodeToObject[T](IJwtDecoder decoder, String token, Byte[] key, Boolean verify) At JWT. JwtDecoderExtensions.DecodeToObject[T](IJwtDecoder decoder, String token, String key, Boolean verify)
According to the flow chart, we try to implement it on the web site, first register the page, as shown in the figure below:
At this time, we will receive an email that reads:
By clicking on the link in the email, you will be taken to our registration form interface, as shown below:
Fill in the username and password information, and click Register to complete the registration, as shown in the figure below:
This article also notes the following points:
- Same IP or same inbox sending frequency
- Record the sending email log
- Blacklist strategy
(End)
|