0
Challenge · 55Routing & Data

Authentication

Coreused in ~85% of apps

Every app eventually needs to know who is calling. Get authentication wrong and you either lock out real users or hand attackers a token to impersonate them — so this is the one feature you must understand at the security level, not just the happy path.

Core idea. Authentication is a two-step loop: the user proves who they are once (credentials), the server hands back a token, and the client attaches that token to every later request so the server can re-verify identity without asking for the password again. The whole game is then about where that token lives.
Playground, this isn't a screenshot
where does the token live?
Browser (client)

Guest

no credentials

cookie jar
empty
Server (the real lock)

Verifies the password, signs the token with a secret only it holds, and re-checks the token on every request.

POST /login
-> verify password
-> sign JWT, return
You are a guest — no token yet. Pick where the token will live, then log in.
HttpOnly = JS can't read it localStorage = any script can read it
↑ play a little first, then dig in