Concept
A JWT is a signed set of claims the server issues and later verifies without a lookup. Keep them short-lived, verify the signature and expiry on every request, and put only what the server needs inside.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show JWT access tokens doing its job.
import { SignJWT, jwtVerify } from "jose";
const secret = new TextEncoder().encode(process.env.JWT_SECRET);
const token = await new SignJWT({ sub: user.id, role: user.role })
.setProtectedHeader({ alg: "HS256" })
.setIssuedAt()
.setExpirationTime("15m")
.sign(secret);
const { payload } = await jwtVerify(token, secret, { algorithms: ["HS256"] });Accepting whatever algorithm the token header names, including "none". Pin the algorithms you issue, and never put secrets in the payload: it is only base64, readable by anyone.
Your roadmap puts these before JWT access tokens, unless you already know them.
Once a session shows you understand JWT access tokens, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on JWT access tokens.