Skip to content

Instantly share code, notes, and snippets.

@zycon
Created May 24, 2021 10:50
Show Gist options
  • Save zycon/1475e78d8131420583a2545f725cfc76 to your computer and use it in GitHub Desktop.
Save zycon/1475e78d8131420583a2545f725cfc76 to your computer and use it in GitHub Desktop.
Postgres Azure RBAC
##Creating user
CREATE USER read_u PASSWORD 'any-password';
##Creating role
create role client_readonly;
###Select the database that you need to grant the access then execute the queries
##Select public table too if neccessary
GRANT USAGE ON SCHEMA client_schema TO client_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA client_schema TO client_readonly;
##Making sure the future created tables in the schema have this rule enabled
ALTER DEFAULT PRIVILEGES IN SCHEMA client_schema GRANT SELECT ON TABLES TO client_readonly;
#Granting the user the role
GRANT client_readonly TO read_u;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment