0
Challenge · 49Auth: Who Is Asking?
Server sessions: getClaims vs getUser vs getSession
Authused in ~95% of apps
Every Supabase + Next.js tutorial protects a page with roughly the same six lines: read the session, check if it exists, redirect if not. Three different Supabase methods can fill in that blank, they all compile, they all "work" in a five-minute demo — and one of them lets anyone who can edit a cookie in their browser's dev tools skip your login page entirely, on your server, in production. This is the single most-cited auth mistake of 2026, and it is invisible until someone forges a cookie on purpose.
Core idea. getSession() reads whatever is sitting in cookie storage and returns it as-is — no verification, so it is not proof of anything. getUser() sends that session's JWT to Supabase's Auth server, which checks it is real; always authentic, always a network round trip. getClaims() verifies the JWT's cryptographic signature locally, using a cached public key — authentic, and usually free of any network call at all. Server code that makes an authorization decision must use getClaims() by default, reach for getUser() only when it specifically needs the freshest possible state, and must never treat getSession() as proof of who is asking.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
| getSession() | getUser() | getClaims() | |
|---|---|---|---|
| What it does | Reads storage/cookies as-is | Asks the Auth server to check | Verifies the signature locally |
| Network call? | No | Yes — every call | Usually none (asymmetric keys) |
| Cryptographically verified? | No | Yes | Yes |
| Safe to authorize with, server-side? | Never | Yes — pay the round trip when freshness matters | Yes — the 2026 default |
↑ play a little first, then dig in