Abbi Labs

Tools · Guides

Supabase RLS policy generator (free, runs in your browser)

By Abbi Labs · Last updated 19 November 2026

Add your tables, choose who can read, insert, update and delete each one, and copy the SQL. You get enable row level security, one policy per operation using (select auth.uid()), and the explicit GRANTs that new tables need since Supabase stopped exposing them to the Data API automatically.

Runs entirely in your browser. Your table names and choices never leave this page. No sign-up.

Your SQL

-- Generated by the free Abbi Labs Supabase RLS policy generator (abbilabs.xyz/tools/supabase-rls-policy-generator).
-- Review it, then run it in the Supabase SQL editor or add it to a migration. Test as signed out, then as two different users.

-- ===== public.todos =====
alter table public.todos enable row level security;

-- Grants: since Supabase's Data API change (default for new projects from 30 May 2026, applied to existing projects on 30 Oct 2026),
-- new tables in public are not reachable through supabase-js / REST until you grant them. Grants say whether a role can reach
-- the table at all; the policies below decide which rows.
revoke all on table public.todos from anon, authenticated;
grant select, insert, update, delete on table public.todos to authenticated;
grant select, insert, update, delete on table public.todos to service_role;
-- If the id is a serial/bigserial (not uuid or identity), inserts also need: grant usage on sequence public.todos_id_seq to authenticated;

-- Index the owner column so (select auth.uid()) = user_id stays fast on big tables.
create index if not exists todos_user_id_idx on public.todos (user_id);

drop policy if exists "todos: owner select" on public.todos;
create policy "todos: owner select" on public.todos for select to authenticated using ((select auth.uid()) = user_id);
drop policy if exists "todos: owner insert" on public.todos;
create policy "todos: owner insert" on public.todos for insert to authenticated with check ((select auth.uid()) = user_id);
drop policy if exists "todos: owner update" on public.todos;
create policy "todos: owner update" on public.todos for update to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
drop policy if exists "todos: owner delete" on public.todos;
create policy "todos: owner delete" on public.todos for delete to authenticated using ((select auth.uid()) = user_id);

-- Owner column: user_id should be uuid not null default auth.uid() references auth.users (id) on delete cascade.

-- Test: signed out, private tables return no rows; as user A you see only A's rows; inserting or updating a row to user B's id fails.
-- Then run a free outside scan of your live app at https://abbilabs.xyz/#scan

The four choices

What changed on 30 October 2026

Supabase used to grant select, insert, update, delete on every new public table to anon, authenticated and service_role, so a table was reachable through supabase-js the moment it existed. New projects stopped doing that from 30 May 2026 and existing projects followed on 30 October 2026 (Supabase changelog). Tables that already existed kept their grants. New ones now return 42501 permission denied for table until you grant access. RLS works the same as before: grants decide whether a role can reach a table, policies decide which rows.

The tempting quick fix is grant all ... to anon with RLS off. That makes the error go away and puts every row on the internet. Grant only what each role needs and keep RLS on, which is what this generator writes. More in fixing 42501 with a GRANT, not by turning off RLS.

After you run it

  1. Test signed out with your anon key: private tables return no rows.
  2. Sign in as user A and user B: each sees only their own rows, and inserting or updating a row with the other's id fails. The SQL editor runs as postgres and skips RLS, so test as a real user.
  3. Audit everything else on the project with the free RLS policy checker.
  4. Scan your live app from outside (below) to confirm nothing is readable with the public key.

Now check what your live app actually exposes

The free Abbi Labs quick check finds your Supabase URL and public key in your site's JavaScript and tests whether tables return rows to a signed-out visitor. It also looks for secret keys in your bundles, exposed .env and .git files, and missing security headers. Read-only, no sign-up.

No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.

Run on every deploy or use from Cursor / Claude Code via MCP →

FAQ

Does this send my table names anywhere?

No. The SQL is built by JavaScript on this page. Your table names, columns and choices aren't sent to Abbi Labs or anyone else, and there's no sign-up.

Why does it add GRANT statements?

Supabase changed its default: new projects since 30 May 2026, and every existing project from 30 October 2026, no longer give anon, authenticated and service_role automatic access to new tables in the public schema. Until you grant a role access, supabase-js gets a 42501 "permission denied" error. Grants decide whether a role can reach the table at all; RLS policies decide which rows. You need both, and the generator grants only the operations you allowed.

Why (select auth.uid()) instead of auth.uid()?

Wrapping it in a select lets Postgres evaluate it once per query instead of once per row, which Supabase recommends for performance on large tables. The result is the same.

What does "Revoke existing grants first" do?

Existing tables still have Supabase's old default grants (select, insert, update, delete and more for anon and authenticated). Revoking first and then granting only what you picked means a role can't even reach an operation you set to "Nobody", which is a useful second lock if a policy is ever loosened by mistake.

Is "Any signed-in user" safe?

Only for data every user should share. Sign-up is open on most Supabase projects, so "any signed-in user" is one free account away from public. For anything per user, choose "Row owner only".

Does it check the policies I already have?

No, it writes new ones. To audit the policies and grants already on your project, use the free Supabase RLS policy checker: it reads them with one read-only query and flags open INSERT/UPDATE checks, using (true), and RLS that is off.

Related

Weekly AI-app security checklist

One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.