@@ -33,3 +33,35 @@ order by
33
33
pgbouncer | get_auth | supabase_admin
34
34
(1 row)
35
35
36
+ -- Tests role privileges on the pgbouncer objects
37
+ -- INSERT and UPDATE privileges should not be present on the pgbouncer tables for postgres and service_role, only SELECT and DELETE
38
+ WITH schema_obj AS (
39
+ SELECT oid, nspname
40
+ FROM pg_namespace
41
+ WHERE nspname = 'pgbouncer'
42
+ )
43
+ SELECT
44
+ s.nspname AS schema,
45
+ c.relname AS object_name,
46
+ acl.grantee::regrole::text AS grantee,
47
+ acl.privilege_type
48
+ FROM pg_class c
49
+ JOIN schema_obj s ON s.oid = c.relnamespace
50
+ CROSS JOIN LATERAL aclexplode(c.relacl) AS acl
51
+ WHERE c.relkind IN ('r', 'v', 'm', 'f', 'p')
52
+ AND acl.privilege_type <> 'MAINTAIN'
53
+ UNION ALL
54
+ SELECT
55
+ s.nspname AS schema,
56
+ p.proname AS object_name,
57
+ acl.grantee::regrole::text AS grantee,
58
+ acl.privilege_type
59
+ FROM pg_proc p
60
+ JOIN schema_obj s ON s.oid = p.pronamespace
61
+ CROSS JOIN LATERAL aclexplode(p.proacl) AS acl
62
+ ORDER BY object_name, grantee, privilege_type;
63
+ schema | object_name | grantee | privilege_type
64
+ -----------+-------------+----------------+----------------
65
+ pgbouncer | get_auth | pgbouncer | EXECUTE
66
+ pgbouncer | get_auth | postgres | EXECUTE
67
+ pgbouncer | get_auth | supabase_admin | EXECUTE
0 commit comments