Created
May 24, 2021 10:50
-
-
Save zycon/1475e78d8131420583a2545f725cfc76 to your computer and use it in GitHub Desktop.
Postgres Azure RBAC
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
##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