-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@YuryHrytsuk review: rm mount on postgres db
- Loading branch information
Showing
3 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...nitdb.d/create-readonly-user.sql.template → ...scripts/create-readonly-user.sql.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |