-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-roles.sql
62 lines (34 loc) · 1.19 KB
/
bootstrap-roles.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- anonymous
CREATE ROLE anonymous;
ALTER USER anonymous WITH NOCREATEDB;
ALTER USER anonymous WITH NOSUPERUSER;
ALTER USER anonymous WITH NOCREATEROLE;
ALTER USER anonymous WITH NOLOGIN;
ALTER USER anonymous WITH NOREPLICATION;
ALTER USER anonymous WITH NOBYPASSRLS;
-- authenticated
CREATE ROLE authenticated;
ALTER USER authenticated WITH NOCREATEDB;
ALTER USER authenticated WITH NOSUPERUSER;
ALTER USER authenticated WITH NOCREATEROLE;
ALTER USER authenticated WITH NOLOGIN;
ALTER USER authenticated WITH NOREPLICATION;
ALTER USER authenticated WITH NOBYPASSRLS;
-- administrator
CREATE ROLE administrator;
ALTER USER administrator WITH NOCREATEDB;
ALTER USER administrator WITH NOSUPERUSER;
ALTER USER administrator WITH NOCREATEROLE;
ALTER USER administrator WITH NOLOGIN;
ALTER USER administrator WITH NOREPLICATION;
-- they CAN bypass RLS
ALTER USER administrator WITH BYPASSRLS;
-- app user
CREATE ROLE app_user LOGIN PASSWORD 'app_password';
GRANT anonymous TO app_user;
GRANT authenticated TO app_user;
-- admin user
CREATE ROLE app_admin LOGIN PASSWORD 'admin_password';
GRANT anonymous TO administrator;
GRANT authenticated TO administrator;
GRANT administrator TO app_admin;