How To Add JWT Authentication To An ASP.NET Core API

Step by step guide to user authentication using ASP.NET Core 7, Identity, PostgreSQL

Jacob Toftgaard Rasmussen
Geek Culture

--

Screenshot of the react app, (from the follow-up guide), that will make requests to the API

The goal

After completing this guide you will have created an ASP.NET 7 web API that exposes a secure endpoint. The secure endpoint can only be accessed by users who have a registered account in your system. To store the user data you will be spinning up a PostgreSQL docker container, and you will learn how to use Identity for user management. All in all, this is the guide for you who want create an ASP.NET Core web API with JWT authentication.
In a follow up article you will learn how to create a small React app with an interface for signing up, logging in, and accessing the secure endpoint.

Prerequisites

To best be able to follow and code along I recommend that you have experience with, (or at least are not frightened), by the following technologies:

  • C#
  • Docker (don’t worry, this is not a big deal in this guide)
  • PostgreSQL (also not a big deal)

As well as the following tools:

  • Visual studio or Rider
  • Docker or another way to connect to a PostgreSQL…

--

--

Jacob Toftgaard Rasmussen
Geek Culture

I explore the wonderful world of software engineering. I write guides, informative articles and silly projects ;) — Keep learning!