Enabling token-based authentication with JSON Web Token

One of the most used authentication mechanisms is a token-based authentication system. With this technique, each time the user logs in, a token is generated and sent back in the response. The token is a hashed and signed value that can later be validated by the server to ensure its authenticity. After the client receives the token, it sends it back with each request (as a header), and the server will extract the user details from the token (if it's valid). Using tokens gives you a few benefits:

  • Secure: Because the value is signed (and sometimes even ciphered), the server can be sure that the values are valid. Another added benefit in the security aspect is that, unlike with cookie-based ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.