A little secret to rock your YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

NestJs JWT - Access Tokens u0026 Refresh Tokens - Ultimate Guide

Follow
Code with Vlad

In this video, I will be building a complete authentication module with logout and refresh functionality. I will also show how you can use access tokens and refresh tokens with passport js and nestJs.

If you love this video consider leaving me a like to help with the youtube algorithm and subscribing if you haven't.

Github repo of the project: https://github.com/vladwulf/nestjsjwts

00:00 NestJs Jwt Authentication Intro
08:58 Prisma and Docker setup
19:35 Prisma service
23:00 Auth module
39:50 Setting up Passport strategies
47:00 NestJs Jwt Module
54:00 Updating refresh token hash
1:02:40 Logout function
1:06:00 Jwt Guards
1:12:00 Refresh tokens function
1:19:00 Get Current User decorator
1:29:00 Access token and Refresh token guards
1:30:00 Access token guard can activate

IMPORTANT: Please use argon for hashing and verifying refresh tokens (https://www.npmjs.com/package/argon2). Bcrypt is only good for short passwords (less than 74 bytes). Since our refresh token is a JWT, it will be longer than 74 bytes, so our bcrypt compare function might return true when it should not!

posted by tavajameif