|
| 1 | +-- storage schema owner |
| 2 | +select |
| 3 | + n.nspname as schema_name, |
| 4 | + r.rolname as owner |
| 5 | +from |
| 6 | + pg_namespace n |
| 7 | +join |
| 8 | + pg_roles r on n.nspowner = r.oid |
| 9 | +where |
| 10 | + n.nspname = 'storage'; |
| 11 | + schema_name | owner |
| 12 | +-------------+---------------- |
| 13 | + storage | supabase_admin |
| 14 | +(1 row) |
| 15 | + |
| 16 | +-- attributes of the supabase_storage_admin |
| 17 | +select |
| 18 | + rolcreaterole , |
| 19 | + rolcanlogin , |
| 20 | + rolsuper , |
| 21 | + rolinherit , |
| 22 | + rolcreatedb , |
| 23 | + rolreplication , |
| 24 | + rolconnlimit , |
| 25 | + rolbypassrls , |
| 26 | + rolvaliduntil |
| 27 | +from pg_roles r |
| 28 | +where r.rolname = 'supabase_storage_admin'; |
| 29 | + rolcreaterole | rolcanlogin | rolsuper | rolinherit | rolcreatedb | rolreplication | rolconnlimit | rolbypassrls | rolvaliduntil |
| 30 | +---------------+-------------+----------+------------+-------------+----------------+--------------+--------------+--------------- |
| 31 | + t | t | f | f | f | f | -1 | f | |
| 32 | +(1 row) |
| 33 | + |
| 34 | +select |
| 35 | + rolconfig |
| 36 | +from pg_roles r |
| 37 | +where r.rolname = 'supabase_storage_admin'; |
| 38 | + rolconfig |
| 39 | +------------------------------------------ |
| 40 | + {search_path=storage,log_statement=none} |
| 41 | +(1 row) |
| 42 | + |
| 43 | +-- storage schema tables with owners and rls policies |
| 44 | +select |
| 45 | + ns.nspname as schema_name, |
| 46 | + c.relname as table_name, |
| 47 | + r.rolname as owner, |
| 48 | + c.relrowsecurity as rls_enabled, |
| 49 | + string_agg(p.polname, ', ' order by p.polname) as rls_policies |
| 50 | +from |
| 51 | + pg_class c |
| 52 | +join |
| 53 | + pg_namespace ns on c.relnamespace = ns.oid |
| 54 | +join |
| 55 | + pg_roles r on c.relowner = r.oid |
| 56 | +left join |
| 57 | + pg_policy p on p.polrelid = c.oid |
| 58 | +where |
| 59 | + ns.nspname = 'storage' |
| 60 | + and c.relkind = 'r' |
| 61 | +group by |
| 62 | + ns.nspname, c.relname, r.rolname, c.relrowsecurity |
| 63 | +order by |
| 64 | + c.relname; |
| 65 | + schema_name | table_name | owner | rls_enabled | rls_policies |
| 66 | +-------------+------------+------------------------+-------------+-------------- |
| 67 | + storage | buckets | supabase_storage_admin | f | |
| 68 | + storage | migrations | supabase_storage_admin | f | |
| 69 | + storage | objects | supabase_storage_admin | t | |
| 70 | +(3 rows) |
| 71 | + |
| 72 | +-- storage indexes with owners |
| 73 | +select |
| 74 | + ns.nspname as table_schema, |
| 75 | + t.relname as table_name, |
| 76 | + i.relname as index_name, |
| 77 | + r.rolname as index_owner |
| 78 | +from |
| 79 | + pg_class t |
| 80 | +join |
| 81 | + pg_namespace ns on t.relnamespace = ns.oid |
| 82 | +join |
| 83 | + pg_index idx on t.oid = idx.indrelid |
| 84 | +join |
| 85 | + pg_class i on idx.indexrelid = i.oid |
| 86 | +join |
| 87 | + pg_roles r on i.relowner = r.oid |
| 88 | +where |
| 89 | + ns.nspname = 'storage' |
| 90 | +order by |
| 91 | + t.relname, i.relname; |
| 92 | + table_schema | table_name | index_name | index_owner |
| 93 | +--------------+------------+---------------------+------------------------ |
| 94 | + storage | buckets | bname | supabase_storage_admin |
| 95 | + storage | buckets | buckets_pkey | supabase_storage_admin |
| 96 | + storage | migrations | migrations_name_key | supabase_storage_admin |
| 97 | + storage | migrations | migrations_pkey | supabase_storage_admin |
| 98 | + storage | objects | bucketid_objname | supabase_storage_admin |
| 99 | + storage | objects | name_prefix_search | supabase_storage_admin |
| 100 | + storage | objects | objects_pkey | supabase_storage_admin |
| 101 | +(7 rows) |
| 102 | + |
| 103 | +-- storage schema functions with owners |
| 104 | +select |
| 105 | + n.nspname as schema_name, |
| 106 | + p.proname as function_name, |
| 107 | + r.rolname as owner |
| 108 | +from |
| 109 | + pg_proc p |
| 110 | +join |
| 111 | + pg_namespace n on p.pronamespace = n.oid |
| 112 | +join |
| 113 | + pg_roles r on p.proowner = r.oid |
| 114 | +where |
| 115 | + n.nspname = 'storage' |
| 116 | +order by |
| 117 | + p.proname; |
| 118 | + schema_name | function_name | owner |
| 119 | +-------------+---------------+------------------------ |
| 120 | + storage | extension | supabase_storage_admin |
| 121 | + storage | filename | supabase_storage_admin |
| 122 | + storage | foldername | supabase_storage_admin |
| 123 | + storage | search | supabase_storage_admin |
| 124 | +(4 rows) |
| 125 | + |
| 126 | +-- roles which have USAGE on the storage schema |
| 127 | +select |
| 128 | + n.nspname as schema_name, |
| 129 | + r.rolname as role_name, |
| 130 | + a.privilege_type |
| 131 | +from |
| 132 | + pg_namespace n |
| 133 | +cross join lateral aclexplode(n.nspacl) as a |
| 134 | +join |
| 135 | + pg_roles r on a.grantee = r.oid |
| 136 | +where |
| 137 | + n.nspname = 'storage' |
| 138 | + and a.privilege_type = 'USAGE' |
| 139 | +order by |
| 140 | + r.rolname; |
| 141 | + schema_name | role_name | privilege_type |
| 142 | +-------------+------------------------+---------------- |
| 143 | + storage | anon | USAGE |
| 144 | + storage | authenticated | USAGE |
| 145 | + storage | dashboard_user | USAGE |
| 146 | + storage | postgres | USAGE |
| 147 | + storage | service_role | USAGE |
| 148 | + storage | supabase_admin | USAGE |
| 149 | + storage | supabase_storage_admin | USAGE |
| 150 | +(7 rows) |
| 151 | + |
| 152 | +-- roles which have CREATE on the storage schema |
| 153 | +select |
| 154 | + n.nspname as schema_name, |
| 155 | + r.rolname as role_name, |
| 156 | + a.privilege_type |
| 157 | +from |
| 158 | + pg_namespace n |
| 159 | +cross join lateral aclexplode(n.nspacl) as a |
| 160 | +join |
| 161 | + pg_roles r on a.grantee = r.oid |
| 162 | +where |
| 163 | + n.nspname = 'storage' |
| 164 | + and a.privilege_type = 'CREATE' |
| 165 | +order by |
| 166 | + r.rolname; |
| 167 | + schema_name | role_name | privilege_type |
| 168 | +-------------+------------------------+---------------- |
| 169 | + storage | dashboard_user | CREATE |
| 170 | + storage | postgres | CREATE |
| 171 | + storage | supabase_admin | CREATE |
| 172 | + storage | supabase_storage_admin | CREATE |
| 173 | +(4 rows) |
| 174 | + |
0 commit comments