Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

postgres: Adding docs for creating a read only user. #2168

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ entries:
- file: docs/products/postgresql/howto/use-pgvector
title: Enable and use pgvector
- file: docs/products/postgresql/howto/pg-object-size
- file: docs/products/postgresql/howto/readonly-user
- file: docs/products/postgresql/howto/list-replication-migration
title: Migrate
entries:
Expand Down
1 change: 1 addition & 0 deletions docs/products/postgresql/howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Aiven for PostgreSQL® how-tos
- :doc:`Prevent PostgreSQL® full disk issues </docs/products/postgresql/howto/prevent-full-disk>`
- :doc:`Enable and use pgvector on Aiven for PostgreSQL® </docs/products/postgresql/howto/use-pgvector>`
- :doc:`Check size of a database, a table or an index </docs/products/postgresql/howto/pg-object-size>`
- :doc:`Restrict access to databases or tables in Aiven for PostgreSQL®". </docs/products/postgresql/howto/readonly-user>`

.. dropdown:: Migration

Expand Down
6 changes: 5 additions & 1 deletion docs/products/postgresql/howto/list-dba-tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ Database administration tasks

.. grid-item-card:: :doc:`Check size of a database, a table or an index </docs/products/postgresql/howto/pg-object-size>`
:shadow: md
:margin: 2 2 0 0
:margin: 2 2 0 0

.. grid-item-card:: :doc:`Restrict access to databases or tables in Aiven for PostgreSQL®". </docs/products/postgresql/howto/readonly-user>`
:shadow: md
:margin: 2 2 0 0
28 changes: 28 additions & 0 deletions docs/products/postgresql/howto/readonly-user.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Restrict access to databases or tables in Aiven for PostgreSQL®
===============================================================

You can restrict access to Aiven for PostgreSQL® databases and tables by setting up read-only permissions for specific user's roles.

Set read-only access in a schema
--------------------------------

1. Modify default permissions for a user's role in a particular schema.

.. code-block:: bash

alter default privileges for role name_of_role in schema name_of_schema YOUR_GRANT_OR_REVOKE_PERMISSIONS

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.

1. Create a new database which will be used as a template ``create database ro_<name>_template...``.
2. For the new template database, set permissions and roles that you want as default ones in the template.
3. When creating a new database, use ``create database NAME with template = 'ro_<name>_template'``.
Loading