ShipGuardScan a site

Supabase RLS SQL generator

Enable Row Level Security and generate starter policies for your tables. Free, client-side, nothing is sent anywhere. See the RLS checklist for how to test the result.

-- Generated by ShipGuard RLS generator. Review before running: it assumes an owner column
-- that stores auth.uid(). Run in the Supabase SQL editor on a branch/staging project first.

-- public.profiles (owner)
alter table public.profiles enable row level security;
revoke all on table public.profiles from anon;
create policy "profiles: owners read" on public.profiles for select to authenticated using ((select auth.uid()) = user_id);
create policy "profiles: owners insert" on public.profiles for insert to authenticated with check ((select auth.uid()) = user_id);
create policy "profiles: owners update" on public.profiles for update to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
create policy "profiles: owners delete" on public.profiles for delete to authenticated using ((select auth.uid()) = user_id);

-- public.projects (owner)
alter table public.projects enable row level security;
revoke all on table public.projects from anon;
create policy "projects: owners read" on public.projects for select to authenticated using ((select auth.uid()) = user_id);
create policy "projects: owners insert" on public.projects for insert to authenticated with check ((select auth.uid()) = user_id);
create policy "projects: owners update" on public.projects for update to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
create policy "projects: owners delete" on public.projects for delete to authenticated using ((select auth.uid()) = user_id);

-- public.messages (owner)
alter table public.messages enable row level security;
revoke all on table public.messages from anon;
create policy "messages: owners read" on public.messages for select to authenticated using ((select auth.uid()) = user_id);
create policy "messages: owners insert" on public.messages for insert to authenticated with check ((select auth.uid()) = user_id);
create policy "messages: owners update" on public.messages for update to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
create policy "messages: owners delete" on public.messages for delete to authenticated using ((select auth.uid()) = user_id);

Review before running. Test on a staging/branch project, then verify with the anon key and two test users.