RLS Policy Generator

Visual builder for Supabase Row Level Security

Schema

· Table structure
5 columns

Access Rules

· Who can do what
sel
ins
upd
del
anon
auth
owner
owner check: auth.uid() = user_id

Row Preview

· Visual access map
Simulating auth.uid() = 7a6b…2d
id785de5c2…
titleHello world
contentLorem ipsum dolor.
anon
auth
owner
owned
ida4693192…
titleWelcome
contentFirst post.
anon
auth
owner
idd1758e72…
titleRoadmap
contentPublic notice.
anon
auth
owner
owned
visible
editable

SQL Output

· Live preview
-- RLS Policy Generator
-- Table: posts

CREATE TABLE posts (
  id uuid,
  title text,
  content text,
  user_id uuid,
  created_at timestamptz
);

-- Enable Row Level Security
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;

-- anon can SELECT
CREATE POLICY "anon_select_posts" ON posts
  FOR SELECT TO anon
  USING (true);

-- authenticated can SELECT
CREATE POLICY "authenticated_select_posts" ON posts
  FOR SELECT TO authenticated
  USING (true);

-- owner can SELECT their own rows
CREATE POLICY "owner_select_posts" ON posts
  FOR SELECT TO authenticated
  USING (auth.uid() = user_id);

-- owner can INSERT their own rows
CREATE POLICY "owner_insert_posts" ON posts
  FOR INSERT TO authenticated
  WITH CHECK (auth.uid() = user_id);

-- owner can UPDATE their own rows
CREATE POLICY "owner_update_posts" ON posts
  FOR UPDATE TO authenticated
  USING (auth.uid() = user_id)
  WITH CHECK (auth.uid() = user_id);

-- owner can DELETE their own rows
CREATE POLICY "owner_delete_posts" ON posts
  FOR DELETE TO authenticated
  USING (auth.uid() = user_id);