GeekCoding101 make your way to geek

Auth101: Web Authentication Tutorials in Node.js

3 posts on auth101series, newest first.

3posts
2023first post

Auth101 is GeekCoding101’s series on how web authentication actually works. It has three hands-on posts covering password authentication, HTTP Basic Auth and JWT, each built in Node.js. Read them in order: each one builds on the idea of “who is making this request?” from the post before.

Start here: reading order

#PostWhat you’ll learnRead time
1Password Authentication in Node.js: A Step-by-Step Guide (Jul 23, 2023)The classic username + password check, and how to build it step by step in Node.js7 min
2HTTP Basic Authentication Explained (RFC 7617) (Oct 1, 2023)The Authorization header, Base64-encoded username:password, why it needs HTTPS, and a Node.js + TypeScript middleware example7 min
3Unlocking Web Security: Master JWT Authentication (Jan 15, 2024)JWT claims, token structure and signing algorithms, then JWT authentication from scratch in Node.js with complete, runnable example code12 min

Total reading time is about 26 minutes.

How the three methods compare

Password loginHTTP Basic AuthJWT
What the client sendsUsername and password, once at loginBase64 username:password in the Authorization header on every requestA signed token, usually in the Authorization: Bearer header
Is the secret protected by the format?No, it relies on HTTPS and on server-side password storageNo. Base64 is encoding, not encryption, so HTTPS is requiredThe signature stops tampering. The payload is readable unless it is also encrypted
Typical useLogin forms for user-facing appsSimple internal tools, quick API protectionAPIs and services that verify requests without a server-side session lookup
Covered inPart 1Part 2Part 3

FAQ

What is the Auth101 series? It is a set of GeekCoding101 tutorials on web authentication fundamentals. The three posts cover password authentication, HTTP Basic Auth and JWT, each with Node.js code you can follow on your own machine.

In what order should I read the posts? Start with password authentication, then HTTP Basic Auth, then JWT. The list below the table shows newest first. The table above gives the learning order.

Is HTTP Basic Authentication secure? Only over HTTPS. Basic Auth sends username:password encoded in Base64, and anyone who can see the request can decode it. Part 2 explains why and shows a Node.js middleware example.

What’s the difference between HTTP Basic Auth and JWT? With Basic Auth, the client sends its credentials on every request. With JWT, the client sends a signed token that the server can verify instead. Parts 2 and 3 cover each in detail.

Is it free? Yes. Every post on GeekCoding101 is free to read, with no sign-up.