Skip to content

Commit

Permalink
@YuryHrytsuk review: rm mount on postgres db
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 1, 2024
1 parent 4779d4e commit 7a6761a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,6 @@ tests/public-api/osparc_python_wheels/*

# osparc-config repo files
repo.config

# scripts resolved with .env s
services/postgres/scripts/create-readonly-user.sql
2 changes: 0 additions & 2 deletions services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,6 @@ services:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_READONLY_PASSWORD: ${POSTGRES_READONLY_PASSWORD}
POSTGRES_READONLY_USER: ${POSTGRES_READONLY_USER}
volumes:
- postgres_data:/var/lib/postgresql/data
- type: tmpfs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
-- SQL script to create a read-only user and grant privileges


--Create the read-only user with a password
CREATE USER ${POSTGRES_READONLY_USER} WITH PASSWORD '${POSTGRES_READONLY_PASSWORD}';

--Grant CONNECT privilege to the database (e.g., 'foo' is the database name)
GRANT CONNECT ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_READONLY_USER};

--Grant USAGE privilege on the **public** schema
GRANT USAGE ON SCHEMA public TO ${POSTGRES_READONLY_USER};

--Grant SELECT privilege on all existing tables and sequencies in the **public** schema
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ${POSTGRES_READONLY_USER};
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO ${POSTGRES_READONLY_USER};

--Ensure that future tables created in the public schema and sequencies will have SELECT privilege for the read-only user
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO ${POSTGRES_READONLY_USER};
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON SEQUENCES TO ${POSTGRES_READONLY_USER};

-- Listing all users
SELECT * FROM pg_roles;

0 comments on commit 7a6761a

Please sign in to comment.