Node.js Authentication Tutorials: From Passwords to JWT
3 posts on nodejs, newest first.
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
| Tutorial | What it covers | Read time |
|---|---|---|
| Password Authentication in Node.js: A Step-by-Step Guide | How username-and-password login works, built step by step in Node.js | 7 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 example | 7 min |
| Unlocking Web Security: Master JWT Authentication | JWT claims, token structure and signing algorithms, then JWT authentication built from scratch in Node.js | 12 min |
- 11 min read
JWT Authentication in Node.js From Scratch
How a JWT works (header, claims, signature, HS256 vs RS256), then build JWT access and refresh tokens from scratch in Node.js and TypeScript.
- 7 min read
HTTP Basic Authentication Explained (RFC 7617)
How HTTP Basic Auth works: the Authorization header, Base64 username:password, why it needs HTTPS, plus a Node.js and TypeScript middleware example.
- 10 min read
Node.js Password Authentication with bcrypt and TypeScript
Build register and login routes in Express and TypeScript, hash passwords with bcryptjs, and see what each part of a bcrypt hash ($2a$10$…) means.
Suggested reading order
The series builds on itself, so the oldest post is the best place to start:
- 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.
- 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.
- 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.