8000 Docker solution to readonly user # 11 · suryatmodulus/postgres@9416c3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 9416c3d

Browse files
committed
Docker solution to readonly user # 11
1 parent fd2c7f2 commit 9416c3d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docker/mnt/00-schema.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Strip everyone on rights to the public schema except for the user postgres
2+
REVOKE ALL ON schema public FROM public;
3+
GRANT ALL ON schema public TO postgres;
4+
5+
6+
-- Provide read only access to the schema and its current content
7+
CREATE ROLE public_readonly;
8+
GRANT CONNECT ON DATABASE postgres TO public_readonly;
9+
GRANT USAGE ON SCHEMA public TO public_readonly;
10+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO public_readonly;
11+
12+
-- Provide read only access to future tables in the schema
13+
ALTER DEFAULT PRIVILEGES IN SCHEMA public
14+
GRANT SELECT ON TABLES TO public_readonly;

0 commit comments

Comments
 (0)
0