An interactive tutorial on web authentication for frontend developers: OAuth 2.0, PKCE and JWTs traced step by step, then localStorage vs HttpOnly cookies.
A frontend app built by Ananda Rizki. More of them at Labs.
Auth Flow
Tutorial
A first-principles tutorial on authentication as a frontend developer meets it. It opens by explaining why a web request has to carry anything at all — HTTP keeps no memory, a password cannot be sent on every request, so the browser carries a stand-in — and only then introduces the four parties OAuth 2.0 defines. Then ten traced conversations, each drawn as a sequence diagram with the actual request beside every step: what a token replaced and why the server stopped remembering you; the authorization code flow one message at a time, with every parameter named and glossed; what PKCE adds and the exact problem it solves, using RFC 7636's own published test vector recomputed locally; why the implicit flow was retired, and the difference between RFC 9700 saying SHOULD NOT and RFC 10017 saying MUST NOT; a real JWT taken apart to show that the payload is base64url rather than ciphertext, that editing a claim breaks the signature, and that signed is not secret; and how an ID token differs from an access token, a distinction most tutorials blur. The second half is the decision: the same cross-site scripting and the same cross-site request forgery run against localStorage and an HttpOnly cookie at the same time, side by side, with what survives each — and the honest conclusion, which is that HttpOnly converts token theft into session riding rather than granting immunity, and that neither choice touches the attack the current best current practice considers worst. Then refresh tokens and rotation, including where rotation's detection provably fails, and the backend-for-frontend pattern that RFC 10017 strongly recommends instead. It is defensive throughout: mechanisms and mitigations, never payloads. Nothing is asserted without a citation, every credential on screen is fabricated, and the cookie claims — what SameSite=Lax really stops, and the two-minute grace period the attribute-less default still grants a cross-site POST — were measured in headless Chrome rather than repeated.
Built by Ananda Rizki, a software engineer and designer, one of the small web apps he writes for fun.
Explore more apps on Labs