Skip to content

Commit a9c198a

Browse files
authored
feat(migrations): predefined role grants (#1815)
* feat(migrations): predefined role grants - supabase_etl_admin needs pg_monitor to query system catalog tables (e.g. pg_replication_slots) - supabase_read_only_user needs pg_monitor to view queries in pg_stat_statements - grant pg_create_subscription to postgres with admin option in case users want to create subscriptions with their own roles * chore: bump version * test: update * chore: bump versions
1 parent 7efb009 commit a9c198a

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: 17.5.1.037-orioledb
14-
postgres17: 17.6.1.016
15-
postgres15: 15.14.1.016
13+
postgresorioledb-17: 17.5.1.038-orioledb
14+
postgres17: 17.6.1.017
15+
postgres15: 15.14.1.017
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.19.0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- migrate:up
2+
grant pg_monitor to supabase_etl_admin, supabase_read_only_user;
3+
4+
do $$
5+
declare
6+
major_version int;
7+
begin
8+
select current_setting('server_version_num')::int / 10000 into major_version;
9+
10+
if major_version >= 16 then
11+
grant pg_create_subscription to postgres with admin option;
12+
end if;
13+
end $$;
14+
15+
-- migrate:down

nix/tests/expected/z_15_roles.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ order by
2929
postgres | pg_signal_backend | f
3030
postgres | pgtle_admin | f
3131
postgres | service_role | f
32+
supabase_etl_admin | pg_monitor | f
3233
supabase_etl_admin | pg_read_all_data | f
34+
supabase_read_only_user | pg_monitor | f
3335
supabase_read_only_user | pg_read_all_data | f
3436
supabase_storage_admin | authenticator | f
35-
(19 rows)
37+
(21 rows)
3638

nix/tests/expected/z_17_roles.out

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ order by
6060
postgres | anon | t
6161
postgres | authenticated | t
6262
postgres | authenticator | t
63-
postgres | pg_create_subscription | f
63+
postgres | pg_create_subscription | t
6464
postgres | pg_monitor | t
6565
postgres | pg_read_all_data | t
6666
postgres | pg_signal_backend | t
6767
postgres | pgtle_admin | f
6868
postgres | service_role | t
69+
supabase_etl_admin | pg_monitor | f
6970
supabase_etl_admin | pg_read_all_data | f
71+
supabase_read_only_user | pg_monitor | f
7072
supabase_read_only_user | pg_read_all_data | f
7173
supabase_storage_admin | authenticator | f
72-
(21 rows)
74+
(23 rows)
7375

7476
-- Check version-specific privileges of the roles on the schemas
7577
select schema_name, privilege_type, grantee, default_for
@@ -158,8 +160,10 @@ order by
158160
postgres | pg_signal_backend | t
159161
postgres | pgtle_admin | f
160162
postgres | service_role | t
163+
supabase_etl_admin | pg_monitor | f
161164
supabase_etl_admin | pg_read_all_data | f
165+
supabase_read_only_user | pg_monitor | f
162166
supabase_read_only_user | pg_read_all_data | f
163167
supabase_storage_admin | authenticator | f
164-
(20 rows)
168+
(22 rows)
165169

0 commit comments

Comments
 (0)