0
Challenge · 05Setup, the Mental Model & Your First Secure App
The vertical slice: your first secure app
Modelused in ~90% of apps
You now know the theory: the browser talks to Postgres through PostgREST, and RLS is the bouncer. That is a sentence you can recite and still not believe until you have personally watched it happen — signed in as one person, on one machine, in one sitting. This concept is that sitting: sign in, write a row, flip one switch, and open a second browser tab as someone else to watch your own data disappear from it. No new theory. Just the thing concept 0 promised, actually running.
Core idea. A vertical slice is a thin path through every layer of the stack, end to end, rather than one layer built in full. Here the slice is four moves: (1) sign in as a real user and get a JWT, (2) insert a row as that user, (3) enable RLS on the table with no policy yet — and watch every caller, including the author, get nothing, and (4) add one policy and open a second session as a different user to prove the first user's private row is invisible to them, not merely hidden by the UI.
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
-- you just ran: create table posts …
Aalice's app
select * from posts#1Why I switched to Postgres
#2Draft: my RLS notesprivate
#3Ships on Fridays
Bbob's app
select * from posts#1Why I switched to Postgres
#2Draft: my RLS notesprivate
#3Ships on Fridays
Bob is reading Alice's private draft. This is the leak.
The table is wide open. The same query hands every row to both identities — Bob is reading Alice's private draft. Nothing is stopping him.
One query. Two identities. Different answers. No
where clause chooses who sees what — the policy does, inside Postgres. You do not yet understand howthat clause works; that is Tiers 9–10. This concept exists to make you want the answer.↑ play a little first, then dig in