Supabase row-level security, explained in plain words
A Supabase app talks to Postgres straight from the browser with a public key. That is safe only when the database itself decides who may read and write each row. That rule is row-level security (RLS).
What goes wrong without it
A table without RLS is readable by anyone holding the public key, and that key ships in your web page. One forgotten table can expose every customer's records.
What a policy looks like
RLS is switched on per table, then policies say which rows a signed-in user may see. A typical one lets members read rows that belong to their own workspace:
using (workspace_id in (select workspace_id from members where user_id = auth.uid()))
Harder cases
- Roles: staff may edit, clients may only read their own bookings.
- Writes that touch several tables, like taking a booking and an invoice together, are safer as one checked database function than as many client calls.
- Public pages need their own narrow read rule, not a switched-off table.
How Tervane handles it
Tervane goes one step further than policies. Every table has RLS switched on and forced with no policies at all, so the public key can read nothing directly. Every read and write goes through a checked database function that applies your roles. Tervane then probes each app the way a stranger would, for example trying to read bookings without signing in, and flags anything that gets through.