Track 07 · Lesson 18 of 18Identity and login
- 01Authentication vs authorization
- 02Browser storage compared
- 03Sessions versus tokens
- 04Inside a JWT
- 05Access and refresh tokens
- 06Where to keep tokens
- 07Choosing a design
- 08The login lifecycle
- 09The token clock
- 10Dead or just unlucky? Refresh decisions
- 11Inside a secure session cookie
- 12Five tabs, one refresh
- 13“Log in with Google”: OAuth and PKCE
- 14Two-factor login
- 15Storing passwords
- 16Logging out properly
- 17Trade-offs and common mistakes
- 18Compare the designs
Compare the designs
Lesson 18 of 18· 6 min
Auth has two separate questions that people often mix up. How do you prove who you are? (password, social login, passkey, magic link). How do you stay signed in afterwards? (sessions, tokens, cookies, a BFF). Your answers can be chosen independently.
Every design side by side
Pick a row for the full explanation
| Approach | Long-lived credential safe from XSS | Safe from CSRF by default | Instant logout on the server | Stays signed in silently | Works with an existing separate API | Low build and run effort |
|---|---|---|---|---|---|---|
| ✕ No | ✓ Yes | ✕ No | ◐ Partly | ✓ Yes | ✓ Yes | |
| ✓ Yes | ◐ Partly | ✓ Yes | ✓ Yes | ✕ No | ◐ Partly | |
| ✓ Yes | ◐ Partly | ◐ Partly | ✓ Yes | ✕ No | ◐ Partly | |
| ✓ Yes | ✓ Yes | ◐ Partly | ✓ Yes | ✓ Yes | ◐ Partly | |
| ✓ Yes | ◐ Partly | ◐ Partly | ✓ Yes | ✓ Yes | ✕ No | |
| ◐ Partly | ◐ Partly | ◐ Partly | ✓ Yes | ◐ Partly | ◐ Partly | |
| ✓ Yes | ✓ Yes | ◐ Partly | ✓ Yes | ◐ Partly | ✓ Yes |
BFF + sealed refresh cookie · your setup
Only auth traffic goes through a small same-origin server that seals the refresh token in an HttpOnly, SameSite=Strict cookie. Everyday calls go direct with a short-lived JWT. Logout revokes the refresh token immediately; an already-issued access token lives until it expires.
When it fits: Most of the safety of a full BFF at a fraction of the cost, with almost no backend changes.
Staying signed in#
Seven common approaches, scored against six questions: is the long-lived credential safe from XSS, is it safe from CSRF by default, can the server log someone out instantly, does it stay signed in silently, does it work with an existing separate API, and how much does it cost to build and run. “Partly” means it depends on configuration. Your setup from the decision helper is marked.
Proving who you are#
Passwords with optional 2FA are universal; social sign-in and passkeys remove the password to steal; magic links are only as safe as the inbox; enterprise SSO is expected by larger customers; and API keys are for machines, never people.
Where this track leaves you#
You can now read any web app’s auth and answer the questions that matter: where the secrets live, how they’re refreshed, what happens when something fails, and how a session really ends. The next track turns to attacks, and you’ll recognize most of the defenses.
Check yourself