RLS policy patterns
This page collects 8 common RLS permission patterns for Postgres-Native cloud storage. You can copy and paste them straight into your project. Naming aligns with PostgreSQL database — RLS policy patterns on purpose — the same mental model applies to both business tables and cloud storage.
Common prerequisites
All the templates below assume:
- The bucket already exists (see Quick experience).
- RLS is already enabled on
storage.objects/storage.buckets(handled by initialization). - You do not need to
GRANT ... ON storage.objects— the three roles already haveALL, and the only gate is RLS. auth.uid()returns the current user ID; see Authentication.
1. PUBLIC — fully open
Use cases: static site assets, public artwork, image hosting served via CDN.
CREATE POLICY public_select ON storage.objects
FOR SELECT TO anon, authenticated
USING (bucket_id = 'public-assets');
CREATE POLICY public_insert ON storage.objects
FOR INSERT TO anon, authenticated
WITH CHECK (bucket_id = 'public-assets');
| Operation | anon | authenticated | service_role |
|---|---|---|---|
| SELECT | ✅ | ✅ | ✅ |
| INSERT | ✅ | ✅ | ✅ |
| UPDATE | ❌ | ❌ | ✅ |
| DELETE | ❌ | ❌ | ✅ |
In practice you usually require sign-in for
INSERT.