When you enroll through our links, we may earn a small commission—at no extra cost to you. This helps keep our platform free and inspires us to add more value.

SkillShare logo

Authentication & Authorization in . NET 6 with JSON Web Tokens (JWT), Refresh Tokens & Roles

Unlock creativity with Skillshare! Learn acrylic painting, AI writing, graphic design, and photography.

     0 |
  • Reviews ( 0 )
Free

This Course Includes

  • iconskillshare
  • icon0 (0 reviews )
  • icon1 hours 45 minutes
  • iconenglish
  • iconOnline - Self Paced
  • iconcourse
  • iconSkillShare

About Authentication & Authorization in . NET 6 with JSON Web Tokens (JWT), Refresh Tokens & Roles

Introduction

Class Overview

Create the Project

Add the User Model

Add the Authentication Controller

First Test with SwaggerUI

Add the Authentication Service

Inject the Service (Dependency Injection)

GitHub Repo

Create the Password Hash

Add the DataContext & Entity Framework Core

Install EF Core Tools

Utilize Code First Migrations

Open the Database with the DB Browser for SQLite

Store User in the Database

Add an AuthResponseDto

Verify the Password

Implement the Login Method

Create and return a JSON Web Token

Add a Secured Endpoint for Authorized Users

Use the JWT with SwaggerUI & the Authentication Middleware

Refresh Tokens Introduction

Add Refresh Token Data to the User Model

Create the Refresh Token on Login

Set Refresh Token in Cookie & in the Database

Refresh the Refresh Token (and the JSON Web Token)

Roles Introduction

Add Role to User Model

Add Role as Claim to the JSON Web Token

Use the Role for Authorization

Closing Words

What You Will Learn?

  • Welcome to the "Authentication & Authorization in . NET 6" class..
  • In this class, you will learn how to.
  • You will learn all that in one single project using .NET 6 and Visual Studio 2022..
  • A little experience with C#, .NET, and creating Web APIs is definitely an advantage..
  • I hope you're ready! Let's start..