Skip to content

Commit

Permalink
Fix granting privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasyu888 committed Oct 17, 2023
1 parent 8a59f87 commit 41daf90
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 49 deletions.
25 changes: 13 additions & 12 deletions admin/roles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,27 @@ TO ROLE recover_data_analytics;

// AD
USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS ad_team;
CREATE ROLE IF NOT EXISTS AD;
USE ROLE SECURITYADMIN;
GRANT ROLE ad_team
GRANT ROLE AD
TO ROLE useradmin;
GRANT ROLE ad_team
GRANT ROLE AD
TO USER "[email protected]";
GRANT USAGE ON DATABASE sage
TO ROLE ad_team;
TO ROLE AD;

// Public role
// Synapse data warehouse
// GRANT SELECT ON ALL TABLES IN SCHEMA synapse_data_warehouse.synapse TO ROLE PUBLIC;
GRANT SELECT ON FUTURE TABLES IN SCHEMA synapse_data_warehouse.synapse
TO ROLE PUBLIC;
GRANT USAGE ON FUTURE SCHEMAS IN DATABASE sage
TO ROLE PUBLIC;
GRANT SELECT ON FUTURE TABLES IN DATABASE sage
TO ROLE PUBLIC;
GRANT USAGE ON DATABASE sage
TO ROLE PUBLIC;
-- TODO: Add these back in after governance
-- GRANT SELECT ON FUTURE TABLES IN SCHEMA synapse_data_warehouse.synapse
-- TO ROLE PUBLIC;
-- GRANT USAGE ON FUTURE SCHEMAS IN DATABASE sage
-- TO ROLE PUBLIC;
-- GRANT SELECT ON FUTURE TABLES IN DATABASE sage
-- TO ROLE PUBLIC;
-- GRANT USAGE ON DATABASE sage
-- TO ROLE PUBLIC;

USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS masking_admin;
Expand Down
34 changes: 4 additions & 30 deletions elt/AD_setup.sql
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
use role sysadmin;
use database sage;
use database SAGE;

create or replace schema ad_team
create schema IF NOT EXISTS AD
WITH MANAGED ACCESS;

use role securityadmin;
grant ALL PRIVILEGES on schema sage_test.ad_team to role ad_team;
grant ALL PRIVILEGES on future tables in schema sage_test.ad_team to role sysadmin;
grant ALL PRIVILEGES on schema SAGE.AD to role ad_team;
grant ALL PRIVILEGES on future tables in schema SAGE.ad_team to role sysadmin;
-- grant all privileges on table sage_test.ad_team.diverse_cohorts_fileview to role sysadmin;

use role ad_team;
use database sage;
use schema ad_team;
COPY INTO "SAGE"."AD_TEAM"."DIVERSE_COHORTS_FILEVIEW"
FROM '@"SAGE"."AD_TEAM"."%DIVERSE_COHORTS_FILEVIEW"/__snowflake_temp_import_files__/'
FILES = ('Job-301735543709776341820576351.csv')
FILE_FORMAT = (
TYPE=CSV,
SKIP_HEADER=1,
FIELD_DELIMITER=',',
TRIM_SPACE=FALSE,
FIELD_OPTIONALLY_ENCLOSED_BY='"',
DATE_FORMAT=AUTO,
TIME_FORMAT=AUTO,
TIMESTAMP_FORMAT=AUTO
)
ON_ERROR=ABORT_STATEMENT
PURGE=TRUE;

SELECT *
FROM sage.ad_team.diverse_cohorts_fileview
limit 10;

SELECT distinct("study")
FROM sage.portal_raw.AD;
8 changes: 1 addition & 7 deletions elt/synapse_gold.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
USE ROLE SYSADMIN;
use database synapse_data_warehouse;
use schema synapse;
use role securityadmin;
// GRANT SELECT ON ALL TABLES IN SCHEMA synapse_data_warehouse.synapse TO ROLE PUBLIC;
REVOKE SELECT ON ALL TABLES IN SCHEMA synapse_data_warehouse.synapse
FROM ROLE PUBLIC;
REVOKE SELECT ON FUTURE TABLES IN SCHEMA synapse_data_warehouse.synapse
FROM ROLE PUBLIC;
-- GRANT SELECT ON FUTURE TABLES IN SCHEMA synapse_data_warehouse.synapse TO ROLE PUBLIC;

// Create certified quiz question latest
CREATE TABLE IF NOT EXISTS synapse_data_warehouse.synapse.certifiedquizquestion_latest AS
select distinct * from synapse_data_warehouse.synapse_raw.certifiedquizquestion
Expand Down

0 comments on commit 41daf90

Please sign in to comment.