Can supautils.policy_grants authorize CREATE POLICY on storage.objects for the postgres role? #54463
Replies: 2 comments 3 replies
|
Short answer: yes, 1. select rolname, rolbypassrls from pg_roles where rolname = 'service_role';If that returns 2. What On one of my own PG 17 projects, 3. Checking without changing anything. These are read-only: select current_user; -- should be postgres when the script runs
select current_setting('supautils.policy_grants', true); -- your role -> storage.objects entry
select tableowner from pg_tables where schemaname = 'storage' and tablename = 'objects';As far as I know, no catalog view answers "will this DDL be allowed?" ahead of time. supautils checks it in a hook when the statement runs. If you want certainty before the real install, Postgres DDL is transactional, so you can dry-run it and roll back: begin;
create policy melovia_storage_admin_all on storage.objects
for all to service_role
using (bucket_id in ('melovia-audio', 'melovia-covers'))
with check (bucket_id in ('melovia-audio', 'melovia-covers'));
rollback;If you get a permission error, nothing was created. If it succeeds, the |
|
AI-assisted answer; I'm not affiliated with Supabase. Tested with supautils v4.0.1 on local PostgreSQL 17.10, not hosted. Agree with codewithcid on 1. Yes (README). It checks the exact current role: a role that only inherits 2. Not by itself. Without supautils loaded, SELECT name, setting, context FROM pg_settings WHERE name='supautils.policy_grants';3. I can't confirm hosted 17.11. 4. I found no read-only way to test the DDL itself. The begin/rollback dry-run does execute DDL and holds an ACCESS EXCLUSIVE lock on BEGIN;
SET LOCAL lock_timeout = '500ms';
CREATE POLICY melovia_storage_admin_all
ON storage.objects FOR ALL TO service_role
USING (bucket_id IN ('melovia-audio', 'melovia-covers'))
WITH CHECK (bucket_id IN ('melovia-audio', 'melovia-covers'));
ROLLBACK;A "lock timeout" error means it waited, not that it was denied. |
Uh oh!
There was an error while loading. Please reload this page.
Hello Supabase community,
I'm preparing a database installation for a small music-sharing application using Supabase Free, and I need to verify one specific permission before proceeding.
Environment
Supabase plan: Free
Region: Paris (eu-west-3)
PostgreSQL version: 17.11
Current database role: postgres
Supautils extension: loaded
What I have verified through read-only SQL diagnostics
The postgres role is not the owner of storage.objects.
RLS is enabled on storage.objects.
The postgres role has the relevant ordinary SQL privileges on storage.objects.
The supautils.policy_grants configuration contains an entry for the postgres role that includes storage.objects.
Two existing public SELECT policies on storage.objects are present and correctly configured.
A third policy named melovia_storage_admin_all does not yet exist.
My installation script needs to execute a statement equivalent to:
CREATE POLICY melovia_storage_admin_all
ON storage.objects
FOR ALL
TO service_role
USING (bucket_id IN ('melovia-audio', 'melovia-covers'))
WITH CHECK (bucket_id IN ('melovia-audio', 'melovia-covers'));
My questions
Does supautils.policy_grants explicitly allow the postgres role to execute CREATE POLICY on storage.objects, even though it is not the table owner?
Is the presence of the postgres / storage.objects entry in this setting sufficient to establish that the permission is active?
Is this behavior supported on Supabase-hosted PostgreSQL 17.11?
Is there an official, read-only way to verify that Supautils will authorize this specific DDL operation, without actually executing CREATE POLICY?
I understand that ordinary PostgreSQL privilege checks do not necessarily reveal permissions granted through Supautils hooks.
I have not attempted to create the policy, run a test DDL statement, or modify any database configuration. I want to establish the behavior before running the installation script.
Any technical explanation, documentation reference, or confirmation from someone familiar with Supautils internals would be greatly appreciated.
Thank you!
All reactions