O'Reilly logo

ASP.NET Core: Cloud-ready, Enterprise Web Application Development by James Singleton, Valerio De Sanctis, Mugilan T. S. Ragupathi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing JSON web token authentication

In order to handle JWT-based token authentication, we need to implement the required middleware for doing these tasks:

  • Generating the JWT tokens upon username/password POST requests coming from our client.
  • Validating any JWT token coming with requests by looking at their headers and cookies

Although ASP.NET Core natively supports JWT tokens, the only available middleware is the one validating the request headers (JwtBearerMiddleware). This leaves us with two choices: manually implement what's missing or rely on a third-party library that does just that. We'll try the hand-made route throughout the rest of this chapter, leaving the other alternative to the following chapter.

The first thing to do is define ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required