@@ -30,19 +30,31 @@ views in that schema:
30
30
(2, 'appuser', '{SELECT,INSERT,UPDATE,DELETE}',
31
31
'VIEW', 'appschema');
32
32
33
+ Of course, the user will need the ` USAGE ` privilege on the schema:
34
+
35
+ INSERT INTO public.permission_target
36
+ (id, role_name, permissions,i
37
+ object_type, schema_name)
38
+ VALUES
39
+ (3, 'appuser', '{USAGE}',
40
+ 'SCHEMA', 'appschema');
41
+
33
42
The user also needs ` USAGE ` privileges on the ` appseq ` sequence in
34
43
that schema:
35
44
36
- INSERT INTO public.permission_target VALUES
37
- (3, 'appuser', '{USAGE}',
38
- 'SEQUENCE', 'appschema', 'appseq', NULL);
45
+ INSERT INTO public.permission_target
46
+ (id, role_name, permissions,
47
+ object_type, schema_name, object_name)
48
+ VALUES
49
+ (4, 'appuser', '{USAGE}',
50
+ 'SEQUENCE', 'appschema', 'appseq');
39
51
40
52
Now we can review which permissions are missing and which additional
41
53
permissions are granted:
42
54
43
55
SELECT * FROM public.permission_diffs();
44
56
45
- missing | role_name | object_type | schema_name | object_name | column_name | permission
57
+ missing | role_name | object_type | schema_name | object_name | column_name | permission
46
58
---------+-----------+-------------+-------------+-------------+-------------+------------
47
59
f | laurenz | VIEW | appschema | appview | | SELECT
48
60
t | appuser | TABLE | appschema | apptable | | DELETE
@@ -53,6 +65,18 @@ That means that `appuser` is missing the `DELETE` privilege on
53
65
has the additional ` SELECT ` privilege on ` appschema.appview ` (` missing `
54
66
is ` FALSE ` ).
55
67
68
+ To review the actual permissions on an object, we can use the ` *_permissions `
69
+ views:
70
+
71
+ SELECT * FROM schema_permissions
72
+ WHERE role_name = 'appuser' AND schema_name = 'appschema';
73
+
74
+ object_type | role_name | schema_name | object_name | column_name | permissions | granted
75
+ -------------+-----------+-------------+-------------+-------------+-------------+---------
76
+ SCHEMA | appuser | appschema | | | USAGE | t
77
+ SCHEMA | appuser | appschema | | | CREATE | f
78
+ (2 rows)
79
+
56
80
Usage
57
81
-----
58
82
0 commit comments