Row Level Security (RLS)
Secure your tables with PostgreSQL Row Level Security policies managed from the Postbase dashboard.
Row Level Security (RLS)
Row Level Security (RLS) is a PostgreSQL feature that lets you control which rows a user can read or modify, based on their identity. Postbase manages RLS policies from the Database → RLS tab in the dashboard.
Enable RLS on a Table
Open the RLS tab, select a table from the sidebar, and click Enable Row Level Security. Postbase runs:
ALTER TABLE "proj_<id>"."your_table" ENABLE ROW LEVEL SECURITY;Create a Policy
Click New Policy to open the policy builder. Fill in:
Policy Name — a unique identifier
Behavior — Permissive (OR-ed) or Restrictive (AND-ed)
Command — SELECT, INSERT, UPDATE, DELETE, or ALL
USING expression — controls which existing rows are visible/modifiable
WITH CHECK expression — controls which new rows can be inserted/updated
User Identity in Policies
Postbase sets postbase.user_id before each query. Reference it in your policies:
-- Allow users to see only their own rows
CREATE POLICY "Users see own rows" ON posts
FOR SELECT
USING (user_id = current_setting('postbase.user_id', true)::uuid);Note: Supabase-style
auth.uid()is not available in plain PostgreSQL. Usecurrent_setting('postbase.user_id', true)::uuidinstead.