|
| 1 | +-- auth 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 = 'auth'; |
| 11 | + schema_name | owner |
| 12 | +-------------+---------------- |
| 13 | + auth | supabase_admin |
| 14 | +(1 row) |
| 15 | + |
| 16 | +-- attributes of the supabase_auth_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_auth_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_auth_admin'; |
| 38 | + rolconfig |
| 39 | +--------------------------------------------------------------------------------- |
| 40 | + {search_path=auth,idle_in_transaction_session_timeout=60000,log_statement=none} |
| 41 | +(1 row) |
| 42 | + |
| 43 | +-- auth schema tables with owners |
| 44 | +select |
| 45 | + n.nspname as schema_name, |
| 46 | + c.relname as table_name, |
| 47 | + r.rolname as owner |
| 48 | +from |
| 49 | + pg_class c |
| 50 | +join |
| 51 | + pg_namespace n on c.relnamespace = n.oid |
| 52 | +join |
| 53 | + pg_roles r on c.relowner = r.oid |
| 54 | +where |
| 55 | + c.relkind in ('r') -- 'r' for regular tables |
| 56 | + and n.nspname = 'auth' |
| 57 | +order by |
| 58 | + c.relname; |
| 59 | + schema_name | table_name | owner |
| 60 | +-------------+-------------------+--------------------- |
| 61 | + auth | audit_log_entries | supabase_auth_admin |
| 62 | + auth | instances | supabase_auth_admin |
| 63 | + auth | refresh_tokens | supabase_auth_admin |
| 64 | + auth | schema_migrations | supabase_auth_admin |
| 65 | + auth | users | supabase_auth_admin |
| 66 | +(5 rows) |
| 67 | + |
| 68 | +-- auth indexes with owners |
| 69 | +select |
| 70 | + ns.nspname as table_schema, |
| 71 | + t.relname as table_name, |
| 72 | + i.relname as index_name, |
| 73 | + r.rolname as index_owner |
| 74 | +from |
| 75 | + pg_class t |
| 76 | +join |
| 77 | + pg_namespace ns on t.relnamespace = ns.oid |
| 78 | +join |
| 79 | + pg_index idx on t.oid = idx.indrelid |
| 80 | +join |
| 81 | + pg_class i on idx.indexrelid = i.oid |
| 82 | +join |
| 83 | + pg_roles r on i.relowner = r.oid |
| 84 | +where |
| 85 | + ns.nspname = 'auth' |
| 86 | +order by |
| 87 | + t.relname, i.relname; |
| 88 | + table_schema | table_name | index_name | index_owner |
| 89 | +--------------+-------------------+----------------------------------------+--------------------- |
| 90 | + auth | audit_log_entries | audit_log_entries_pkey | supabase_auth_admin |
| 91 | + auth | audit_log_entries | audit_logs_instance_id_idx | supabase_auth_admin |
| 92 | + auth | instances | instances_pkey | supabase_auth_admin |
| 93 | + auth | refresh_tokens | refresh_tokens_instance_id_idx | supabase_auth_admin |
| 94 | + auth | refresh_tokens | refresh_tokens_instance_id_user_id_idx | supabase_auth_admin |
| 95 | + auth | refresh_tokens | refresh_tokens_pkey | supabase_auth_admin |
| 96 | + auth | refresh_tokens | refresh_tokens_token_idx | supabase_auth_admin |
| 97 | + auth | schema_migrations | schema_migrations_pkey | supabase_auth_admin |
| 98 | + auth | users | users_email_key | supabase_auth_admin |
| 99 | + auth | users | users_instance_id_email_idx | supabase_auth_admin |
| 100 | + auth | users | users_instance_id_idx | supabase_auth_admin |
| 101 | + auth | users | users_pkey | supabase_auth_admin |
| 102 | +(12 rows) |
| 103 | + |
| 104 | +-- auth schema functions with owners |
| 105 | +select |
| 106 | + n.nspname as schema_name, |
| 107 | + p.proname as function_name, |
| 108 | + r.rolname as owner |
| 109 | +from |
| 110 | + pg_proc p |
| 111 | +join |
| 112 | + pg_namespace n on p.pronamespace = n.oid |
| 113 | +join |
| 114 | + pg_roles r on p.proowner = r.oid |
| 115 | +where |
| 116 | + n.nspname = 'auth' |
| 117 | +order by |
| 118 | + p.proname; |
| 119 | + schema_name | function_name | owner |
| 120 | +-------------+---------------+--------------------- |
| 121 | + auth | email | supabase_auth_admin |
| 122 | + auth | role | supabase_auth_admin |
| 123 | + auth | uid | supabase_auth_admin |
| 124 | +(3 rows) |
| 125 | + |
| 126 | +-- roles which have USAGE on the auth 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 = 'auth' |
| 138 | + and a.privilege_type = 'USAGE' |
| 139 | +order by |
| 140 | + r.rolname; |
| 141 | + schema_name | role_name | privilege_type |
| 142 | +-------------+---------------------+---------------- |
| 143 | + auth | anon | USAGE |
| 144 | + auth | authenticated | USAGE |
| 145 | + auth | dashboard_user | USAGE |
| 146 | + auth | postgres | USAGE |
| 147 | + auth | service_role | USAGE |
| 148 | + auth | supabase_admin | USAGE |
| 149 | + auth | supabase_auth_admin | USAGE |
| 150 | +(7 rows) |
| 151 | + |
| 152 | +-- roles which have CREATE on the auth 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 = 'auth' |
| 164 | + and a.privilege_type = 'CREATE' |
| 165 | +order by |
| 166 | + r.rolname; |
| 167 | + schema_name | role_name | privilege_type |
| 168 | +-------------+---------------------+---------------- |
| 169 | + auth | dashboard_user | CREATE |
| 170 | + auth | postgres | CREATE |
| 171 | + auth | supabase_admin | CREATE |
| 172 | + auth | supabase_auth_admin | CREATE |
| 173 | +(4 rows) |
| 174 | + |
0 commit comments