Database / Supabase Intermediate to Advanced Interview Questions
Explain the execution flow of a private Realtime broadcast channel authorized by Row Level Security?
A private Realtime channel starts the same way a public one does — a client calls supabase.channel('room-42', { config: { private: true } }) and attempts to subscribe — but before any messages flow, the Realtime server checks whether that connection's JWT is authorized for this specific channel, rather than allowing any authenticated client onto any channel name.
- The client establishes a WebSocket connection to Realtime, presenting its JWT.
- On a subscribe attempt to a private channel, Realtime queries a Postgres function (or checks a
realtime.channels-linked RLS policy) to determine whether this user is authorized for that channel name. - If the check passes, the subscription is accepted and the client starts receiving Broadcast or Presence events published to that channel; if it fails, the subscription is rejected before any data is sent.
- Every subsequent message published to the channel is delivered only to connections that passed this authorization step, rather than to every WebSocket connected to the server.
This differs from the plain "Postgres Changes" channel type, where authorization is enforced per-row via table RLS on every change event; a private broadcast/presence channel instead authorizes at the channel-subscription level, once, up front — useful for scenarios like a chat room or collaborative document where the "row" being protected isn't a single table row but an entire logical room.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
