0
Challenge · 71Services
Realtime authorization & private channels
Realtimeused in ~55% of apps
Concept 70's trigger broadcasts every comment on topic `post:<id>`. Nothing so far stops a stranger from opening `supabase.channel('post:2')` and simply listening — the topic name is not a secret, and DevLog's acceptance test is specific: a stranger must not be able to subscribe to alice's private draft's comment channel at all. A channel name is not a password. Something has to actually check who's allowed in.
Core idea. A channel opened with `config: { private: true }` is authorized by ordinary RLS policies on `realtime.messages` — a SELECT policy gates joining/listening, an INSERT policy gates sending — evaluated inside a transaction that is always rolled back, so nothing is ever persisted. The verdict is then cached for the life of the connection, which is what makes it cheap; `realtime.topic()` and the `extension` column let the policy know which channel and which feature (broadcast vs presence) it's authorizing.
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
joining private channel "post:2"
The client opens a WebSocket to Realtime with the project's API key.
↑ play a little first, then dig in