GeekCoding101 make your way to geek

Node.js Authentication Tutorials: From Passwords to JWT

3 posts on nodejs, newest first.

3posts
2023first post

Every Node.js post on GeekCoding101 is about authentication. Together they form the three-part Auth101 series: password login, HTTP Basic Authentication and JWT, each with example code you can run yourself. Read them in order to go from the simplest login method to signed, stateless tokens. You can also jump straight to the one you need.

The three tutorials at a glance

TutorialWhat it coversRead time
Password Authentication in Node.js: A Step-by-Step GuideHow username-and-password login works, built step by step in Node.js7 min
HTTP Basic Authentication Explained (RFC 7617)The Authorization header, Base64-encoded username:password, why HTTPS is required, plus a Node.js and TypeScript middleware example7 min
Unlocking Web Security: Master JWT AuthenticationJWT claims, token structure and signing algorithms, then JWT authentication built from scratch in Node.js12 min

Suggested reading order

The series builds on itself, so the oldest post is the best place to start:

  1. Password authentication. Start here: users prove who they are with a username and password. This is still one of the most common login methods online.
  2. HTTP Basic Authentication. Next, see how the browser and server pass those same credentials in a standard HTTP header. The credentials are only Base64-encoded, not encrypted, which is why Basic Auth must run over HTTPS.
  3. JWT authentication. Finally, move to signed tokens. The server issues a token with claims, and each request carries it instead of the password.

Which method should you read about?

  • You need a quick lock on an internal tool or API: HTTP Basic Auth, always over HTTPS.
  • You are building a sign-up and login flow for users: password authentication.
  • You need stateless auth for an API or a single-page app: JWT.

FAQ

Are these tutorials free? Yes. Every post on GeekCoding101 is free to read, with no sign-up.

Is HTTP Basic Auth secure? Only over HTTPS. Base64 is an encoding, not encryption, so anyone who can see the request can decode the username and password. The Basic Auth tutorial explains why and shows the middleware in Node.js and TypeScript.

Is a JWT encrypted? Not by default. A standard JWT is signed, which lets the server detect tampering. Its payload can still be read by anyone holding the token, so keep secrets out of the claims. The JWT tutorial walks through claims, structure and signing algorithms.

Do I need to read the series in order? No. Each post stands on its own. Reading them in order (password, Basic Auth, JWT) does show how each method builds on the one before.