Staging Storage RLS policy — CREATE POLICY ownership permissions #53412
Replies: 2 comments
|
Run the Your diagnostic checks normal Postgres ownership, but Supabase projects load the select current_setting('supautils.policy_grants', true);Then: begin;
create policy "no deletes in seller-documents"
on storage.objects
as restrictive
for delete
to authenticated
using (bucket_id <> 'seller-documents');
commit;A restrictive policy is ANDed with your permissive ones, so On your other points:
|
|
@ShawnRemedios — Sagargupta16's answer is right, and the 1. A delete blocked by RLS doesn't error — it silently affects zero rows. Through the Data API, a delete whose restrictive select polname, polcmd, permissive, roles, qual, with_check
from pg_policies
where schemaname = 'storage' and tablename = 'objects'
order by polcmd, polname;
-- expected: your new row shows polcmd = DELETE, permissive = false (AS RESTRICTIVE),
-- qual = (bucket_id <> 'seller-documents'::text)Then as a real 2. Restrictive can only subtract. The existing permissive policies decide who can delete at all; your restrictive policy ANDs a condition on top of that. So the shape matters: a restrictive policy written as The dashboard editor gap is real and worth reporting as a product issue: the policy editor exposes permissive creation for |
Uh oh!
There was an error while loading. Please reload this page.
Hi Supabase Support,
I'm working on a separate Supabase Staging project called crewsies-staging (Free plan).
We need to create a restrictive DELETE policy on storage.objects to prevent authenticated users from deleting files in our private seller-documents bucket.
Our read-only diagnostics returned:
SQL Editor role: postgres
Table owner: supabase_storage_admin
Superuser: false
Owner-role membership: false
Inherited owner privileges: false
Permission to SET ROLE to the owner: false
The project already contains two restrictive policies on storage.objects for UPDATE and INSERT, but we're unable to establish a supported execution method for a third policy.
The Storage Dashboard's policy editor also doesn't appear to provide an option for AS RESTRICTIVE.
Could you please clarify:
What is the supported method for creating a restrictive RLS policy on storage.objects in this configuration?
Can the SQL Editor execute the required DDL despite the ownership diagnostic?
If not, is there a supported alternative that preserves restrictive-policy behaviour without changing table ownership or granting internal roles?
Can the existing reviewed migration be applied transactionally using that method?
We haven't attempted the migration or changed any database permissions.
Thanks for your guidance.
All reactions