Skip to content
0:00 / 0:00

#jwt#express#authentication

JWT Authentication | Node JS and Express tutorials for Beginners

Dave Gray

447K subscribers • 4 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Dave Gray
  • Linked in the descriptiongitdagray/user_authgitdagray/express_jwt
  • May be out of date. The tools, versions or practices it shows have likely moved on.

Beginner. No background in the topic needed.

159K views5 years ago2 recommendations

Web developmentSecurityNode.js, Deno and BunWeb and application securityJavaScript

Dave Gray demonstrates how to implement secure JWT authentication in a Node.js and Express REST API.

Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap Learn how to apply JWT Authentication to your Node JS and Express REST API routes in the most secure way possible to avoid XSS and CSRF attacks. This beginners tutorial will help you apply JSON Web Tokens to your REST API built with Node.js and Express. 🚩 Subscribe ➜ bit.ly/3nGHmNn 🚀 This tutorial is part of a Node.js & Express for Beginners tutorial series playlist: youtube.com/playlist?list=PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw 🔗 Starter Source Code: github.com/gitdagray/user_auth 🔗 Completed Source Code: github.com/gitdagray/express_jwt JWT Authentication | Node JS and Express tutorials for Beginners () Intro () Welcome () JWT Authentication () Set up () Installing new dependencies () Creating environment variables () Creating JWT tokens at authorization () Creating JWT verification middleware () Applying JWT token verification to specific routes () Applying JWT token verification to many routes () Adding cookie-parser middleware () Creating a refresh token controller () Creating the refresh route () Adding the refresh route to the server () Testing the refresh route () Creating a logout controller () Creating the logout route () Adding the logout route to the server () A Quick Debug () Testing the logout route () Frontend: fetch needs the credentials option () Backend: CORS needs Access-Control-Allow-Credentials () Chrome requires specific cookie options 📚 JWT References: Intro to JSON Web Tokens: jwt.io/introduction All You Need to Know About Storing JWT in the Frontend: dev.to/cotter/localstorage-vs-cookies-all-you-need-to-know-a… NPM jsonwebtoken package: npmjs.com/package/jsonwebtoken NPM cookie-parser package: npmjs.com/package/cookie-parser Deleting Cookies: expressjs.com/en/api.html#res.clearCookie Cross-Site Scripting (XSS): owasp.org/www-community/attacks/xss/ Cross-Site Request Forgery (CSRF): owasp.org/www-community/attacks/csrf REST Security Cheat Sheet: cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_S… 📚 Login References: Bcrypt: npmjs.com/package/bcrypt How to Safely Store a Password: codahale.com/how-to-safely-store-a-password/ MDN: HTTP Response Status Codes: developer.mozilla.org/en-US/docs/Web/HTTP/Status 📚 More References: Node.js Official site: nodejs.org NPM Official site: npmjs.com/ Express JS Official site: expressjs.com/ MDN CORS: developer.mozilla.org/en-US/docs/Web/HTTP/CORS NPM CORS: npmjs.com/package/cors ✅ Follow Me: Twitter: twitter.com/yesdavidgray LinkedIn: linkedin.com/in/davidagray/ Blog: yesdavidgray.com Reddit: www

Why it's here

2 people recommend this

What people say. Recommended as an excellent, easy-to-follow tutorial for implementing JWT authentication in Node.js.

u/mikevalerianoin r/node • Recommends

On “Advice on Authentication”

> but that is not working for some reason. I keep getting some errors and have been at it for a while now. Are you searching using the error messages? You will *definitely* find someone who had the same issues as you. Personally I find the PassportJS "ecosystem" very very bloated and outdated. Take a look at Dave Gray's video on nodejs Auth with jwt. He is an excellent educator, you'll pick it up easily. Might check his whole node series if you wanna learn more about node as a whole.

u/lucidl0gicin r/node • Recommends

On “How are jwt token professionally used to authenticate on a website.I have used only one token which I store and expire every 24 hours.”

Here is the best video i have found for implementstikn: link to this video He also has a video for the frontend and how to handle the token