Files
documentdb/pg_helio_api/sql/rbac/extension_readonly_setup--1.17-1.sql
T
Deepak Pemmaraju 009b69d31e Merged PR 1400474: Adding code for CreateUser, GetUsers, UpdateUser and DropUser
### Does this PR have any customer impact?
It exposes a new API customers can use

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Are you introducing any new config? If yes, do you have tests with and without them being set?
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Adding code for CreateUser, UpdateUser and DropUser

Related work items: #3264072, #3278392, #3292323, #3292361, #3292364, #3315917
2024-08-26 13:12:13 +03:00

22 lines
900 B
SQL

DO
$do$
BEGIN
/*
* The role is a system-wide object which is not dropped if the extension
* is dropped. Therefore, if helioapi is repeatedly created and dropped,
* a regular CREATE ROLE would fail since __API_ADMIN_ROLE__ still exists.
* We therefore only create the role if it does not exist.
*/
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'helio_readonly_role') THEN
CREATE ROLE helio_readonly_role;
END IF;
END
$do$;
GRANT USAGE ON SCHEMA __API_CATALOG_SCHEMA__ TO helio_readonly_role;
GRANT USAGE ON SCHEMA __API_SCHEMA_INTERNAL__ TO helio_readonly_role;
GRANT USAGE ON SCHEMA __API_SCHEMA__ TO helio_readonly_role;
GRANT USAGE ON SCHEMA __API_DATA_SCHEMA__ TO helio_readonly_role;
GRANT SELECT ON TABLE __API_CATALOG_SCHEMA__.collections TO helio_readonly_role;
GRANT SELECT ON TABLE __API_CATALOG_SCHEMA__.collection_indexes TO helio_readonly_role;