You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supautils is an extension that secures PostgreSQL on a cloud environment, where SUPERUSER cannot be granted to users.
5
+
Supautils is an extension that unlocks advanced Postgres features without granting SUPERUSER access.
6
6
7
-
It's completely controlled through settings, it doesn't require database objects (tables, functions or security labels). So it can be configured cluster-wide entirely in `postgresql.conf`.
7
+
It's a loadable library that allows creating event triggers, publications, and other highly privileged database objects on cloud deployments where giving SUPERUSER rights to end users isn’t an option.
8
+
9
+
It's managed entirely by configuration — no tables, functions, or security labels are added to your database. That makes upgrades effortless and lets you apply settings cluster-wide solely via `postgresql.conf`.
8
10
9
11
Tested to work on PostgreSQL 13, 14, 15, 16 and 17.
10
12
@@ -36,6 +38,7 @@ ALTER ROLE role1 SET session_preload_libraries TO 'supautils';
This functionality is adapted from [pgextwlist](https://github.com/dimitri/pgextwlist).
107
+
> [!NOTE]
108
+
> This functionality is adapted from [pgextwlist](https://github.com/dimitri/pgextwlist).
105
109
106
110
supautils allows you to let non-superusers manage extensions that would normally require being a superuser. e.g. the `hstore` extension creates a base type, which requires being a superuser to perform.
107
111
@@ -136,16 +140,6 @@ grant all on type hstore to non_superuser_role;
136
140
137
141
This is useful for things like creating a dedicated role per extension and granting privileges as needed to that role.
You can constrain the resources needed for an extension to be installed. This is done through:
@@ -160,11 +154,10 @@ Each top field of the json object corresponds to an extension name, the only val
160
154
161
155
-`cpu`: is the minimum number of cpus this extension needs. It's a json number.
162
156
-`mem`: is the minimum amount of memory this extension needs. It's a json string that takes a human-readable format of bytes.
157
+
+ The human-readable format is the same that [pg_size_pretty](https://pgpedia.info/p/pg_size_pretty.html) returns.
163
158
-`disk`: is the minimum amount of free disk space this extension needs. It's a json string that takes a human-readable format of bytes.
164
159
+ The free space of the disk is taken from the filesystem where PGDATA (data directory) is located.
165
160
166
-
Note: this human-readable format is the same that [pg_size_pretty](https://pgpedia.info/p/pg_size_pretty.html) would give.
167
-
168
161
`CREATE EXTENSION` will fail if any of the resource constraints are not met:
169
162
170
163
```sql
@@ -202,18 +195,16 @@ postgres=> \dx pg_cron
202
195
203
196
#### Manage Policies
204
197
205
-
In Postgres, only table owners can create RLS policies for a table. This can be
206
-
limiting if you need to allow certain roles to manage policies without allowing
207
-
them to perform other DDL (e.g. to prevent them from dropping the table).
198
+
In Postgres, only table owners can create RLS policies for a table. This can be limiting if you need to allow certain roles to manage policies without allowing them
199
+
to perform other DDL (e.g. to prevent them from dropping the table).
Roles with the CREATEROLE privilege cannot ALTER or DROP the above reserved roles.
246
237
247
-
This extension also allows restricting roles memberships. Certain default postgres roles are dangerous to expose to every database user.
248
-
From [pg default roles](https://www.postgresql.org/docs/11/default-roles.html):
238
+
#### Reserved Roles Settings
239
+
240
+
By default, reserved roles cannot have their settings changed. However their settings can be modified by the [Privileged Role](#privileged-role) if they're configured like so:
Certain default postgres roles are dangerous to expose to every database user. From [pg default roles](https://www.postgresql.org/docs/11/default-roles.html):
249
249
250
250
> The pg_read_server_files, pg_write_server_files and pg_execute_server_program roles are intended to allow administrators to have trusted,
251
251
> but non-superuser, roles which are able to access files and run programs on the database server as the user the database runs as.
252
252
> As these roles are able to access any file on the server file system, they bypass all database-level permission checks when accessing files directly
253
253
> and **they could be used to gain superuser-level access**, therefore great care should be taken when granting these roles to users.
254
254
255
-
For example, you can restrict doing `GRANT pg_read_server_files TO my_role` by setting:
255
+
Supautils allows you to restrict doing `GRANT pg_read_server_files TO my_role` by setting:
By default, reserved roles cannot have their settings changed. However their settings can be modified by the [Privileged Role](#privileged-role) if they're configured like so:
0 commit comments