This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
postgresql: Cleaning up Read Only User docs
Per the comments on the PR, I am fixing these docs to be more presentable.
- Loading branch information
1 parent
6fdc98d
commit f2962d3
Showing
3 changed files
with
25 additions
and
11 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
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,15 +1,25 @@ | ||
Read Only User for PostgreSQL | ||
============================= | ||
In the interest of having users with the least permissions to complete their tasks, one may need a user with read only access to the whole database or a handful of tables. In some cases, we may want this to happen automatically, below are two approaches to complete this task. | ||
Restrict access to databases or tables in Aiven for PostgreSQL® | ||
=============================================================== | ||
This article shows how you can restrict access to Aiven for PostgreSQL® databases and tables by setting up read-only permissions for specific user's roles. | ||
|
||
All new objects shall have a role with read-only permissions | ||
------------------------------------------------------------ | ||
1. Alter the default permissions for the role for the given schema: ``ALTER DEFAULT PRIVILEGES FOR ROLE <target role> IN SCHEMA <schema name> abbreviated_grant_or_revoke`` | ||
Set read-only access in a schema | ||
-------------------------------- | ||
1. Modify default permissions for a user's role in a particular schema. | ||
|
||
2. To update any existing database objects, run the following: ``GRANT SELECT ON ALL TABLES IN SCHEMA <schema name> to <myreadonlyrole>;`` | ||
.. code-block:: bash | ||
ALTER DEFAULT PRIVILEGES FOR ROLE NAME_OF_ROLE IN SCHEMA NAME_OF_SCHEMA abbreviated_grant_or_revoke | ||
2. Apply the new read-only access setting to your existing database objects that uses the affected schema. | ||
|
||
.. code-block:: bash | ||
GRANT SELECT ON ALL TABLES IN SCHEMA NAME_OF_SCHEMA to NAME_OF_READ_ONLY_ROLE | ||
Set read-only access in a database | ||
---------------------------------- | ||
You can set up the read-only access for a specific user's role in a particular database. | ||
|
||
Only certain databases should be read-only for users in a particular role: | ||
========================================================================== | ||
1. Create a new database which will be used as a template ``CREATE DATABASE ro_<name>_template...`` | ||
2. Update the standardizable information of the database | ||
Check failure on line 24 in docs/products/postgresql/howto/readonly-user.rst GitHub Actions / vale[vale] docs/products/postgresql/howto/readonly-user.rst#L24
Raw output
|
||
3. When creating a new database, use ``CREATE DATABASE <name> WITH TEMPLATE = 'ro_<name>_template'`` |