Skip to content

Commit d2c3bc0

Browse files
committed
docs: clarify and shorten
1 parent f57301c commit d2c3bc0

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

README.md

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
[![Coverage Status](https://coveralls.io/repos/github/supabase/supautils/badge.svg?branch=master)](https://coveralls.io/github/supabase/supautils?branch=master)
44

5-
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.
66

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`.
810

911
Tested to work on PostgreSQL 13, 14, 15, 16 and 17.
1012

@@ -36,6 +38,7 @@ ALTER ROLE role1 SET session_preload_libraries TO 'supautils';
3638
- [Extensions Parameter Overrides](#extensions-parameter-overrides)
3739
- [Table Ownership Bypass](#table-ownership-bypass)
3840
- [Reserved Roles](#reserved-roles)
41+
- [Reserved Memberships](#reserved-memberships)
3942

4043
### Privileged Role
4144

@@ -56,12 +59,12 @@ The privileged role can also execute `create foreign data wrapper..`, the logic
5659

5760
#### Non-Superuser Event Triggers
5861

59-
The privileged role is also able to create event triggers, this while adding protection for privilege escalation.
62+
The privileged role is also able to create event triggers, while adding protection for privilege escalation.
6063

6164
To protect against privilege escalation, the event triggers created by the privileged role:
6265

63-
- Will be executed for any non-superuser role.
64-
- Will be skipped for any superuser role.
66+
- Will be executed for non-superusers.
67+
- Will be skipped for superusers.
6568
- Will also be skipped for [Reserved Roles](#reserved-roles).
6669

6770
The skipping behavior can be logged by setting the `supautils.log_skipped_evtrigs` config to true, this is false by default.
@@ -101,7 +104,8 @@ supautils.privileged_role_allowed_configs="ext.*"
101104

102105
### Privileged Extensions
103106

104-
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).
105109
106110
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.
107111

@@ -136,16 +140,6 @@ grant all on type hstore to non_superuser_role;
136140

137141
This is useful for things like creating a dedicated role per extension and granting privileges as needed to that role.
138142

139-
#### Configuration
140-
141-
Settings available:
142-
143-
```
144-
supautils.privileged_extensions = 'hstore,moddatetime'
145-
supautils.privileged_extensions_custom_scripts_path = '/opt/postgresql/privileged_extensions_custom_scripts'
146-
supautils.privileged_extensions_superuser = 'postgres'
147-
```
148-
149143
### Constrained Extensions
150144

151145
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
160154

161155
- `cpu`: is the minimum number of cpus this extension needs. It's a json number.
162156
- `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.
163158
- `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.
164159
+ The free space of the disk is taken from the filesystem where PGDATA (data directory) is located.
165160

166-
Note: this human-readable format is the same that [pg_size_pretty](https://pgpedia.info/p/pg_size_pretty.html) would give.
167-
168161
`CREATE EXTENSION` will fail if any of the resource constraints are not met:
169162

170163
```sql
@@ -202,18 +195,16 @@ postgres=> \dx pg_cron
202195

203196
#### Manage Policies
204197

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).
208200

209201
With supautils, this can be done like so:
210202

211203
```
212204
supautils.policy_grants = '{ "my_role": ["public.not_my_table", "public.also_not_my_table"] }'
213205
```
214206

215-
This allows `my_role` to manage policies for `public.not_my_table` and
216-
`public.also_not_my_table` without being an owner of these tables.
207+
This allows `my_role` to manage policies for `public.not_my_table` and `public.also_not_my_table` without being an owner of these tables.
217208

218209
#### Drop Triggers
219210

@@ -228,7 +219,7 @@ supautils.drop_trigger_grants = '{ "my_role": ["public.not_my_table", "public.al
228219
> [!IMPORTANT]
229220
> The CREATEROLE problem is solved starting from PostgreSQL 16.
230221
231-
Non-superusers with the CREATEROLE privilege can ALTER, DROP or GRANT non-superuser roles without restrictions.
222+
Roles with the CREATEROLE privilege can ALTER, DROP or GRANT other roles without restrictions.
232223

233224
From [role attributes docs](https://www.postgresql.org/docs/15/role-attributes.html):
234225

@@ -244,27 +235,30 @@ supautils.reserved_roles = 'connector, storage_admin'
244235

245236
Roles with the CREATEROLE privilege cannot ALTER or DROP the above reserved roles.
246237

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:
241+
242+
```
243+
supautils.reserved_roles = 'connector*, storage_admin*'
244+
```
245+
246+
### Reserved Memberships
247+
248+
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):
249249

250250
> The pg_read_server_files, pg_write_server_files and pg_execute_server_program roles are intended to allow administrators to have trusted,
251251
> but non-superuser, roles which are able to access files and run programs on the database server as the user the database runs as.
252252
> 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
253253
> and **they could be used to gain superuser-level access**, therefore great care should be taken when granting these roles to users.
254254
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:
256256

257257
```
258258
supautils.reserved_memberships = 'pg_read_server_files'
259259
```
260260

261-
#### Reserved Roles Settings
262-
263-
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:
264-
265-
```
266-
supautils.reserved_roles = 'connector*, storage_admin*'
267-
```
261+
This is also useful to limit memberships to the [Reserved Roles](#reserved-roles).
268262

269263
## Development
270264

0 commit comments

Comments
 (0)