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

View: 29945|Reply: 1

[ASP.NET] .NET JWT-based mailbox validation tutorial

[Copy link]
Posted on 11/8/2020 4:24:43 PM | | | |
About JWT:

Learn about understanding JWT (JSON Web Tokens).
https://www.itsvse.com/thread-4786-1-1.html
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)




Previous:ASP.NET Core link tracing (2) uses SkyAPM integration
Next:Make an online exam system with existing questions
 Landlord| Posted on 9/12/2021 11:31:35 AM |
Parse JWT information onlineThe hyperlink login is visible.
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