forked from ceph/ceph-telemetry
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb_create_roles.sql
More file actions
74 lines (59 loc) · 2.79 KB
/
db_create_roles.sql
File metadata and controls
74 lines (59 loc) · 2.79 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
--CREATE USER grafana WITH PASSWORD '<PASSWORD>';
--CREATE USER grafana_ro WITH PASSWORD '<PASSWORD>';
-- This command must be run as user 'postgres', since user 'telemetry' is not part of 'grafana' role
ALTER MATERIALIZED VIEW device.weekly_reports_sliding OWNER TO grafana;
GRANT USAGE ON SCHEMA grafana TO grafana, grafana_ro;
GRANT ALL ON ALL TABLES IN SCHEMA grafana TO grafana; -- "ALL TABLES" includes views
GRANT ALL ON ALL SEQUENCES IN SCHEMA grafana TO grafana;
GRANT SELECT ON TABLE public.report, public.device_report, public.crash TO grafana;
-- Grant access to grafana on future tables & seq in schema grafana
ALTER DEFAULT PRIVILEGES
FOR ROLE postgres
IN SCHEMA grafana
GRANT ALL ON TABLES TO grafana;
ALTER DEFAULT PRIVILEGES
FOR ROLE postgres
IN SCHEMA grafana
GRANT ALL ON SEQUENCES TO grafana;
GRANT SELECT ON ALL TABLES IN SCHEMA grafana TO grafana_ro;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA grafana TO grafana_ro;
GRANT SELECT ON TABLE public.report, public.device_report, public.crash TO grafana_ro;
ALTER DEFAULT PRIVILEGES
FOR ROLE postgres
IN SCHEMA grafana
GRANT SELECT ON TABLES TO grafana_ro;
ALTER DEFAULT PRIVILEGES
FOR ROLE postgres
IN SCHEMA grafana
GRANT SELECT ON SEQUENCES TO grafana_ro;
--CREATE USER dashboard WITH PASSWORD '<PASSWORD>' NOINHERIT;
CREATE SCHEMA IF NOT EXISTS dashboard;
GRANT USAGE ON SCHEMA dashboard TO dashboard, grafana, grafana_ro;
GRANT CREATE ON SCHEMA dashboard TO grafana;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA dashboard TO dashboard, grafana_ro;
ALTER DEFAULT PRIVILEGES
FOR ROLE grafana
IN SCHEMA dashboard
GRANT EXECUTE ON FUNCTIONS TO dashboard;
GRANT ALL ON ALL TABLES IN SCHEMA dashboard TO grafana;
-- Revoking 'CREATE' permissions from
-- PUBLIC read-only users on 'public' schema:
GRANT CONNECT ON DATABASE telemetry TO postgres, telemetry, grafana, grafana_ro, dashboard;
GRANT CONNECT ON DATABASE postgres TO postgres, telemetry;
GRANT USAGE ON SCHEMA public TO postgres, telemetry, grafana, grafana_ro;
GRANT CREATE ON SCHEMA public TO postgres, telemetry;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public to postgres, telemetry;
GRANT USAGE ON LANGUAGE SQL to postgres, telemetry;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE CONNECT, TEMPORARY ON DATABASE telemetry FROM PUBLIC;
REVOKE CONNECT ON DATABASE postgres FROM PUBLIC;
-- dashboard_device schema roles:
CREATE SCHEMA IF NOT EXISTS dashboard_device;
GRANT USAGE ON SCHEMA dashboard_device TO dashboard, grafana, grafana_ro;
GRANT CREATE ON SCHEMA dashboard_device TO grafana;
GRANT ALL ON ALL TABLES IN SCHEMA dashboard_device TO grafana;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA dashboard_device TO dashboard, grafana_ro;
ALTER DEFAULT PRIVILEGES
FOR ROLE grafana
IN SCHEMA dashboard_device
GRANT EXECUTE ON FUNCTIONS TO dashboard;