@@ -3,6 +3,39 @@ PostgreSQL permission reports and checks
33
44This extension allows you to review object permissions on a PostgreSQL database.
55
6+ Cookbook
7+ --------
8+
9+ First, you have to install the extension in the database:
10+
11+ CREATE EXTENSION pg_permissions SCHEMA public;
12+
13+ Then you need to add entries to ` permission_target ` that correspond to your
14+ desired permissions.
15+
16+ Let's assume we have a schema ` appschema ` , and ` appuser ` should have
17+ ` SELECT ` , ` UPDATE ` , ` DELETE ` and ` INSERT ` permissions on all tables and
18+ views in that schema:
19+
20+ INSERT INTO public.permission_target VALUES
21+ (1, 'appuser', '{SELECT,INSERT,UPDATE,DELETE}',
22+ 'TABLE', 'appschema', NULL, NULL);
23+ INSERT INTO public.permission_target VALUES
24+ (2, 'appuser', '{SELECT,INSERT,UPDATE,DELETE}',
25+ 'VIEW', 'appschema', NULL, NULL);
26+
27+ The user also needs ` USAGE ` privileges on the ` appseq ` sequence in
28+ that schema:
29+
30+ INSERT INTO public.permission_target VALUES
31+ (3, 'appuser', '{USAGE}',
32+ 'SEQUENCE', 'appschema', 'appseq', NULL);
33+
34+ Now we can review which permissions are missing and which additional
35+ permissions are granted:
36+
37+ SELECT * FROM public.permission_diffs();
38+
639Usage
740-----
841
0 commit comments