Skip to content

Commit

Permalink
Separate privileges and users and roles
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasyu888 committed Oct 30, 2023
1 parent bf3144e commit 160e07d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ jobs:
curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.9-linux_x86_64.bash
SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql-1.2.9-linux_x86_64.bash
- name: Create users
run: |
~/bin/snowsql -f users_and_roles/users.sql
- name: Create roles
run: |
~/bin/snowsql -f users_and_roles/roles.sql
- name: Create warehouses
run: |
~/bin/snowsql -f admin/warehouses.sql
Expand All @@ -48,10 +56,6 @@ jobs:
run: |
~/bin/snowsql -f admin/databases.sql
- name: Create users
run: |
~/bin/snowsql -f admin/users.sql
- name: Create integration
run: |
~/bin/snowsql -f admin/integrations.sql --variable saml2_issuer=$saml2_issuer --variable saml2_sso_url=$saml2_sso_url --variable saml2_x509_cert=$saml2_x509_cert
Expand All @@ -60,6 +64,6 @@ jobs:
# run: |
# ~/bin/snowsql -f admin/policies.sql

- name: Roles and granting policies
- name: Grant privileges
run: |
~/bin/snowsql -f admin/roles.sql
~/bin/snowsql -f privileges/grants.sql
43 changes: 15 additions & 28 deletions admin/roles.sql → privileges/grants.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
USE WAREHOUSE COMPUTE_ORG;
USE ROLE SECURITYADMIN;
-- ACCOUNTADMIN privileges
GRANT ROLE ACCOUNTADMIN
TO USER "[email protected]";

// Grant system roles to users
-- SYSADMIN privileges
GRANT ROLE SYSADMIN
TO USER "[email protected]";

GRANT ROLE SYSADMIN
TO USER "[email protected]";

// GENIE
USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS GENIE_ADMIN;
USE ROLE SECURITYADMIN;
-- GENIE privileges
GRANT ROLE GENIE_ADMIN
TO ROLE USERADMIN;
GRANT ROLE GENIE_ADMIN
Expand All @@ -21,12 +20,7 @@ TO USER "[email protected]";
GRANT ROLE GENIE_ADMIN
TO USER "[email protected]";

// RECOVER
USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS RECOVER_DATA_ENGINEER;
CREATE ROLE IF NOT EXISTS RECOVER_DATA_ANALYTICS;

USE ROLE SECURITYADMIN;
-- RECOVER privileges
GRANT ROLE RECOVER_DATA_ENGINEER
TO ROLE USERADMIN;
GRANT ROLE RECOVER_DATA_ANALYTICS
Expand All @@ -38,29 +32,15 @@ TO USER "[email protected]";
GRANT ROLE RECOVER_DATA_ENGINEER
TO USER "[email protected]";

// AD
USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS AD;
USE ROLE SECURITYADMIN;
-- AD privileges
GRANT ROLE AD
TO ROLE USERADMIN;
GRANT ROLE AD
TO USER "[email protected]";

USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS MASKING_ADMIN;
GRANT ROLE MASKING_ADMIN
TO USER "[email protected]";
USE ROLE ACCOUNTADMIN;
GRANT APPLY MASKING POLICY ON ACCOUNT
TO ROLE MASKING_ADMIN;

USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS DATA_ENGINEER;
USE ROLE SECURITYADMIN;
-- Data engineer privileges
GRANT ROLE DATA_ENGINEER
TO ROLE USERADMIN;

GRANT ROLE DATA_ENGINEER
TO USER "[email protected]";
GRANT ROLE DATA_ENGINEER
Expand All @@ -71,3 +51,10 @@ GRANT ROLE DATA_ENGINEER
TO USER "[email protected]";
GRANT ROLE DATA_ENGINEER
TO USER "[email protected]";

-- Create governance privileges
GRANT ROLE MASKING_ADMIN
TO USER "[email protected]";
USE ROLE ACCOUNTADMIN;
GRANT APPLY MASKING POLICY ON ACCOUNT
TO ROLE MASKING_ADMIN;
16 changes: 16 additions & 0 deletions users_and_roles/roles.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
USE WAREHOUSE COMPUTE_ORG;
USE ROLE USERADMIN;

-- system wide roles
CREATE ROLE IF NOT EXISTS MASKING_ADMIN;
CREATE ROLE IF NOT EXISTS DATA_ENGINEER;

-- GENIE roles
CREATE ROLE IF NOT EXISTS GENIE_ADMIN;

-- RECOVER roles
CREATE ROLE IF NOT EXISTS RECOVER_DATA_ENGINEER;
CREATE ROLE IF NOT EXISTS RECOVER_DATA_ANALYTICS;

-- AD
CREATE ROLE IF NOT EXISTS AD;
File renamed without changes.

0 comments on commit 160e07d

Please sign in to comment.