diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..447483b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,50 @@
+# Ignore macOS system files
+.DS_Store
+
+# Ignore Linux system files
+*~
+
+# Ignore Visual Studio Code settings
+.vscode/
+.vscode/*
+
+# Ignore JetBrains IDEs (e.g., IntelliJ, PyCharm, WebStorm, etc.)
+.idea/
+*.iml
+*.iws
+out/
+
+# Ignore common SQL editor/IDE files
+*.sublime-workspace
+*.sublime-project
+
+# Ignore log files
+*.log
+
+# Ignore temporary files created by editors
+*.swp
+*.tmp
+*.bak
+*.old
+*.orig
+
+# Ignore backups
+*.sql.bak
+
+# Ignore compiled binary files
+*.out
+*.o
+*.a
+*.so
+
+# Ignore Thumbs.db (Windows-specific, but in case someone uses Windows)
+Thumbs.db
+
+# Ignore SQL dump files
+*.sql.dump
+
+# Ignore any environment variable files
+.env
+
+# Ignore any other system-specific hidden files
+._*
diff --git a/Baseline/auth/V2__CONFIGURE_PIC_SURE_APPLICATION.sql b/Baseline/auth/V2__CONFIGURE_PIC_SURE_APPLICATION.sql
new file mode 100644
index 0000000..fd0a9a9
--- /dev/null
+++ b/Baseline/auth/V2__CONFIGURE_PIC_SURE_APPLICATION.sql
@@ -0,0 +1,17 @@
+use auth;
+INSERT INTO application VALUES (0x__APPLICATION_UUID__,'PIC-SURE multiple data access API',0x01,'PICSURE','','/picsureui');
+INSERT INTO `privilege` VALUES
+(0x7044061AF65B425F86CE73A1BF7F4402,'PIC-SURE Auth super admin for managing roles/privileges/application/connections','SUPER_ADMIN',NULL,'[]',NULL),
+(0xAD08212E096F414CBA8D1BAE09415DAB,'PIC-SURE Auth admin for managing users.','ADMIN',NULL,'[]',NULL);
+INSERT INTO `privilege` VALUES (0xF65B425F867044061ACE73A1BF7F4402,'User who cann run any PIC-SURE Query','PIC_SURE_ANY_QUERY',0x__APPLICATION_UUID__,'[]',NULL);
+INSERT INTO `role` VALUES (0x002DC366B0D8420F998F885D0ED797FD,'PIC-SURE Top Admin','PIC-SURE Auth Micro App Top admin including Admin and super Admin, can manage roles and privileges directly');
+INSERT INTO `role` VALUES (0x8F885D0ED797FD002DC366B0D8420F99,'Admin','Normal admin users, can manage other users including assignment of roles and privileges');
+INSERT INTO `role` VALUES (0x797FD002DC366B0D8420F998F885D0ED,'PIC-SURE User','Normal user, can run any query including data export.');
+INSERT INTO `connection` VALUES (0x97FD002DC366B0D8420F998F885D0ED7, 'Google', 'google-oauth2','google-oauth2|','[{"label":"Email", "id":"email"}]');
+INSERT INTO `role_privilege` VALUES
+(0x002DC366B0D8420F998F885D0ED797FD,0x7044061AF65B425F86CE73A1BF7F4402),
+(0x002DC366B0D8420F998F885D0ED797FD,0xAD08212E096F414CBA8D1BAE09415DAB),
+(0x8F885D0ED797FD002DC366B0D8420F99,0xAD08212E096F414CBA8D1BAE09415DAB),
+(0x797FD002DC366B0D8420F998F885D0ED,0xF65B425F867044061ACE73A1BF7F4402);
+INSERT INTO `userMetadataMapping` VALUES
+(unhex('17FD002DC366B0D8420F998F885D0ED7'), '$.email', unhex('97FD002DC366B0D8420F998F885D0ED7'), '$.email');
diff --git a/Baseline/auth/V3__CONFIGURE_JUPYTERHUB_APPLICATION.sql b/Baseline/auth/V3__CONFIGURE_JUPYTERHUB_APPLICATION.sql
new file mode 100644
index 0000000..6c62d96
--- /dev/null
+++ b/Baseline/auth/V3__CONFIGURE_JUPYTERHUB_APPLICATION.sql
@@ -0,0 +1,5 @@
+use auth;
+INSERT INTO application VALUES (0xDEADBEEFE9B1458594536ED31D456752,'JupyterHub authentication via PSAMA',0x01,'JupyterHub','','/jupyterhub');
+INSERT INTO `privilege` VALUES (0x530AF81BE8F744AB85E8222D0C743410,'JupyterHub user for accessing notebooks','JUPYTER_USER',0xDEADBEEFE9B1458594536ED31D456752,'[]',NULL);
+INSERT INTO `role` VALUES (0x7EF44B39239318D5B4C2D467580CE4E8,'JupyterHub User','The user is able to access JupyterHub as a normal user');
+INSERT INTO `role_privilege` VALUES (0x7EF44B39239318D5B4C2D467580CE4E8, 0x530AF81BE8F744AB85E8222D0C743410);
diff --git a/Baseline/picsure/V2__CREATE_HPDS_RESOURCE.sql b/Baseline/picsure/V2__CREATE_HPDS_RESOURCE.sql
new file mode 100644
index 0000000..e6fcb47
--- /dev/null
+++ b/Baseline/picsure/V2__CREATE_HPDS_RESOURCE.sql
@@ -0,0 +1,5 @@
+use picsure;
+INSERT INTO `resource`
+ (uuid, targetURL, resourceRSPath, description, name, token, hidden, metadata)
+ VALUES
+ (0x__RESOURCE_UUID__, NULL, 'http://hpds:8080/PIC-SURE/', 'Basic HPDS resource', 'hpds', NULL, FALSE, NULL);
\ No newline at end of file
diff --git a/GIC-Common-Area/auth/V10.1__UPDATE_UTHSC_USER_METADATA_MAPPING.sql b/GIC-Common-Area/auth/V10.1__UPDATE_UTHSC_USER_METADATA_MAPPING.sql
new file mode 100644
index 0000000..be40244
--- /dev/null
+++ b/GIC-Common-Area/auth/V10.1__UPDATE_UTHSC_USER_METADATA_MAPPING.sql
@@ -0,0 +1,4 @@
+INSERT INTO `userMetadataMapping` VALUES
+(unhex('B6BD9D7F9E3311ECA5F4126ACB86EEFB'), '$.email', unhex('97FD002DC366B0D8420F998F885D0ED7'), '$.email');
+
+update connection set id = 'UTHSC' where id = 'uthsc';
\ No newline at end of file
diff --git a/GIC-Common-Area/auth/V10__ADD_UTHSC_CONNECTION.sql b/GIC-Common-Area/auth/V10__ADD_UTHSC_CONNECTION.sql
new file mode 100644
index 0000000..6ddd6f4
--- /dev/null
+++ b/GIC-Common-Area/auth/V10__ADD_UTHSC_CONNECTION.sql
@@ -0,0 +1 @@
+INSERT INTO `connection` VALUES (0xB6BD9D7F9E3311ECA5F4126ACB86EEFB, 'UTHSC', 'uthsc','samlp|UTHSC|','[{"label":"The University of Tennessee Health Science Center Email", "id":"email"}]');
diff --git a/GIC-Common-Area/auth/V11__UPDATE_BCH_CONNECTOR_ADFS.sql b/GIC-Common-Area/auth/V11__UPDATE_BCH_CONNECTOR_ADFS.sql
new file mode 100644
index 0000000..276884e
--- /dev/null
+++ b/GIC-Common-Area/auth/V11__UPDATE_BCH_CONNECTOR_ADFS.sql
@@ -0,0 +1,24 @@
+
+SET @uuidADFSConn = UNHEX(REPLACE(UUID(),'-',''));
+SET @uuidLDAPConn = (select uuid from connection where id='ldap-connector');
+
+-- Create the connection entity for BCH-ADFS
+INSERT INTO `connection` VALUES (@uuidADFSConn, 'BCH-ADFS', 'BCH-ADFS','adfs|BCH-ADFS|','[{"label":"BCH Email", "id":"email"}]');
+
+-- Create the userMetadataMapping for BCH-ADFS
+INSERT INTO `userMetadataMapping` VALUES
+(UNHEX(REPLACE(uuid(), '-', '')), '$.email', @uuidADFSConn, '$.email');
+
+-- Create an ADFS user for each of the ldap-connector users.
+-- We preserve the ability to roll back to the ldap-connector if necessary and also preserve the UUIDs for audit purposes
+ insert into user
+ (select UNHEX(REPLACE(uuid(), '-', '')), NULL, general_metadata, acceptedTOS, @uuidADFSConn, email,0x00,NULL, is_active, NULL
+ from user where connectionId=@uuidLDAPConn);
+
+-- Assign the same roles to the ADFS users that are assigned to the LDAP users
+
+insert into user_role (select b.uuid new_uuid, role_id from
+ (select * from user_role left join user on user_id=uuid where connectionId=@uuidLDAPConn) a
+ left join
+ (select * from user where connectionId=@uuidADFSConn) b on a.email = b.email );
+
diff --git a/GIC-Common-Area/auth/V12__UPDATE_TERMS_OF_SERVICE.sql b/GIC-Common-Area/auth/V12__UPDATE_TERMS_OF_SERVICE.sql
new file mode 100644
index 0000000..311aafb
--- /dev/null
+++ b/GIC-Common-Area/auth/V12__UPDATE_TERMS_OF_SERVICE.sql
@@ -0,0 +1,29 @@
+use auth;
+
+INSERT INTO termsOfService (uuid, dateUpdated, content)
+ VALUES (UNHEX(REPLACE(uuid(),'-','')), CURRENT_TIMESTAMP(),
+ '
+
+
+
Terms and Conditions of Use of the Genomic Information Commons (GIC) Portal
+
+
+
User must select the terms and click “accept” to certify that User agrees to the Terms and Conditions of Use of the GIC Portal:
Terms and Conditions of Use of the Genomic Information Commons (GIC) Portal
+
+
+
User must select the terms and click “accept” to certify that User agrees to the Terms and Conditions of Use of the GIC Portal:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
');
diff --git a/GIC-Common-Area/auth/V14__REPAIR_UTHSC_USER_METADATA_MAPPING.sql b/GIC-Common-Area/auth/V14__REPAIR_UTHSC_USER_METADATA_MAPPING.sql
new file mode 100644
index 0000000..f18f240
--- /dev/null
+++ b/GIC-Common-Area/auth/V14__REPAIR_UTHSC_USER_METADATA_MAPPING.sql
@@ -0,0 +1,9 @@
+use auth;
+
+DELETE
+ FROM `userMetadataMapping`
+ WHERE uuid = unhex('B6BD9D7F9E3311ECA5F4126ACB86EEFB');
+
+INSERT
+ INTO `userMetadataMapping` (uuid, auth0MetadataJsonPath, connectionId, generalMetadataJsonPath)
+ VALUES (unhex('2B464334D120880E2250A7626FC2ED8D'), '$.email', unhex('B6BD9D7F9E3311ECA5F4126ACB86EEFB'), '$.email');
diff --git a/GIC-Common-Area/auth/V15__FIX_WUSTL_CASING.sql b/GIC-Common-Area/auth/V15__FIX_WUSTL_CASING.sql
new file mode 100644
index 0000000..7f92000
--- /dev/null
+++ b/GIC-Common-Area/auth/V15__FIX_WUSTL_CASING.sql
@@ -0,0 +1,6 @@
+use auth;
+
+-- Casing issue: id was lower case. Stuff wasn't matching.
+UPDATE `connection`
+ SET id = 'WUSTL'
+ WHERE label = 'WUSTL';
diff --git a/GIC-Common-Area/auth/V16__CREATE_SECRET_DATAFRAME_RULE.sql b/GIC-Common-Area/auth/V16__CREATE_SECRET_DATAFRAME_RULE.sql
new file mode 100644
index 0000000..0628e0f
--- /dev/null
+++ b/GIC-Common-Area/auth/V16__CREATE_SECRET_DATAFRAME_RULE.sql
@@ -0,0 +1,56 @@
+use auth;
+
+INSERT
+ INTO access_rule (
+ uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode,
+ subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates
+ ) VALUES (
+ unhex(REPLACE(uuid(),'-','')), 'Secret Dataframe', 'Dataframes that cannot be accessed',
+ '$..expectedResultType', 4, 'SECRET_ADMIN_DATAFRAME', 0x00, 0x00, NULL, 0x00, 0x00
+ );
+
+-- We alias the access rule table as 'ar' in the insert query because MYSQL doesn't let you reference the table you are
+-- inserting into directly.
+-- This regex is essentially matching to three cases:
+-- /query
+-- /query//sync
+-- /query//status
+INSERT
+ INTO access_rule (
+ uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode,
+ subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates
+ )
+ VALUES (
+ unhex(REPLACE(uuid(),'-','')), 'Secret Dataframe Query Route Regex', 'Dataframes that cannot be accessed',
+ '$.[\'Target Service\']', 11, '((/query.*/(sync|status))|(/query))$', 0x00, 0x00,
+ (SELECT ar.uuid FROM access_rule as ar WHERE ar.name = 'Secret Dataframe'), 0x00, 0x00
+ );
+
+
+INSERT
+ INTO privilege (uuid, name, description, application_id)
+ VALUES (
+ unhex(REPLACE(uuid(),'-','')), 'SECRET_ADMIN_DATAFRAME', 'Un-viewable dataframe privilege for PICSURE application',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT
+ INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ (SELECT uuid FROM privilege WHERE name = 'SECRET_ADMIN_DATAFRAME'),
+ (SELECT uuid FROM access_rule WHERE name = 'Secret Dataframe')
+ );
+
+INSERT
+ INTO role (uuid, name, description)
+ VALUES (unhex(REPLACE(uuid(),'-','')),
+ 'PIC-SURE Secret Dataframe Requester',
+ 'PIC-SURE Secret Dataframe Requester. Can create dataframes, but cannot view them.'
+ );
+
+INSERT
+ INTO role_privilege (role_id, privilege_id)
+ VALUES (
+ (SELECT uuid FROM role WHERE name = 'PIC-SURE Secret Dataframe Requester'),
+ (SELECT uuid FROM privilege WHERE name = 'SECRET_ADMIN_DATAFRAME')
+ );
\ No newline at end of file
diff --git a/GIC-Common-Area/auth/V17__CREATE_UUID_GEN_RULE.sql b/GIC-Common-Area/auth/V17__CREATE_UUID_GEN_RULE.sql
new file mode 100644
index 0000000..95bb427
--- /dev/null
+++ b/GIC-Common-Area/auth/V17__CREATE_UUID_GEN_RULE.sql
@@ -0,0 +1,38 @@
+use auth;
+
+set @resourceUUID = (SELECT
+ LOWER(CONCAT(
+ SUBSTR(HEX(uuid), 1, 8), '-',
+ SUBSTR(HEX(uuid), 9, 4), '-',
+ SUBSTR(HEX(uuid), 13, 4), '-',
+ SUBSTR(HEX(uuid), 17, 4), '-',
+ SUBSTR(HEX(uuid), 21)
+ )) from picsure.resource where name = "Query-ID-Gen");
+
+SET @uuidRule = REPLACE(UUID(),'-','');
+INSERT
+ INTO access_rule (
+ uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode,
+ subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates
+ ) VALUES (
+ unhex(@uuidRule), 'CREATE_UUID', 'Create common area UUID', '$query.resourceUUID', 4,
+ @resourceUUID, 0x00, 0x00, NULL, 0x00, 0x00
+ );
+
+SET @uuidPriv = REPLACE(UUID(),'-','');
+INSERT
+ INTO privilege (uuid, name, description, application_id)
+ VALUES (
+ unhex(@uuidPriv), 'CREATE_UUID', 'Create common area UUID',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ unhex(@uuidPriv),
+ unhex(@uuidRule)
+ );
+
+SET @uuidRole = (SELECT uuid FROM role WHERE name = 'PIC-SURE User');
+INSERT INTO role_privilege (role_id, privilege_id) VALUES (@uuidRole, unhex(@uuidPriv));
+
diff --git a/GIC-Common-Area/auth/V18__UPDATE_TERMS_OF_SERVICE_2023.sql b/GIC-Common-Area/auth/V18__UPDATE_TERMS_OF_SERVICE_2023.sql
new file mode 100644
index 0000000..ca45cbc
--- /dev/null
+++ b/GIC-Common-Area/auth/V18__UPDATE_TERMS_OF_SERVICE_2023.sql
@@ -0,0 +1,32 @@
+use auth;
+
+INSERT INTO termsOfService (uuid, dateUpdated, content)
+ VALUES (UNHEX(REPLACE(uuid(),'-','')), CURRENT_TIMESTAMP(),
+ '
+
+
+
Terms and Conditions of Use of the Genomic Information Commons (GIC) Portal
+
+
+
User must select the terms and click “accept” to certify that User agrees to the Terms and Conditions of Use of the GIC Portal:
+
+
+
+
+
+
+
+
Research reported in this manuscript was supported by the member institutions of the Genomic Information Commons (GIC) and the National Center for Advancing Translational Sciences of the National Institutes of Health under Award Number(s) U01TR002623. The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health or the GIC.
+
+
+
+
+
+
+
+
+
+
+
+
+
');
diff --git a/GIC-Common-Area/auth/V19__VARIANT_EXPLORER.sql b/GIC-Common-Area/auth/V19__VARIANT_EXPLORER.sql
new file mode 100644
index 0000000..6c0c71c
--- /dev/null
+++ b/GIC-Common-Area/auth/V19__VARIANT_EXPLORER.sql
@@ -0,0 +1,49 @@
+use auth;
+
+SET @resourceUUID = (SELECT
+ LOWER(CONCAT(
+ SUBSTR(HEX(uuid), 1, 8), '-',
+ SUBSTR(HEX(uuid), 9, 4), '-',
+ SUBSTR(HEX(uuid), 13, 4), '-',
+ SUBSTR(HEX(uuid), 17, 4), '-',
+ SUBSTR(HEX(uuid), 21)
+ )) from picsure.resource where name = "Common-Search");
+
+SET @uuidParentRule = REPLACE(UUID(),'-','');
+SET @uuidChildRule = REPLACE(UUID(),'-','');
+
+INSERT
+ INTO access_rule (
+ uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode,
+ subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates
+ ) VALUES (
+ unhex(@uuidParentRule), 'EXPLORE_VARIANT', 'Sync query for variant explorer', '$..expectedResultType', 11,
+ '(VARIANT_COUNT_FOR_QUERY|VCF_EXCERPT|AGGREGATE_VCF_EXCERPT)', 0x00, 0x00, NULL, 0x00, 0x00
+ );
+
+INSERT
+ INTO access_rule (
+ uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode,
+ subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates
+ )
+ VALUES (
+ unhex(@uuidChildRule), 'EXPLORE_VARIANT_URI', 'Sync query for variant explorer',
+ '$.[\'Target Service\']', 4, '/query/sync', 0x00, 0x00,
+ unhex(@uuidParentRule), 0x00, 0x00
+ );
+
+SET @uuidPriv = REPLACE(UUID(),'-','');
+INSERT
+ INTO privilege (uuid, name, description, application_id)
+ VALUES (
+ unhex(@uuidPriv), 'EXPLORE_VARIANT', 'Explore aggregate results for variant',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT
+ INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (unhex(@uuidPriv), unhex(@uuidParentRule));
+
+INSERT
+ INTO role_privilege (role_id, privilege_id)
+ VALUES ((SELECT uuid FROM role WHERE name = 'PIC-SURE User'), unhex(@uuidPriv));
diff --git a/GIC-Common-Area/auth/V20__ADD_SAVE_DATASET_ROLE.sql b/GIC-Common-Area/auth/V20__ADD_SAVE_DATASET_ROLE.sql
new file mode 100644
index 0000000..58e580a
--- /dev/null
+++ b/GIC-Common-Area/auth/V20__ADD_SAVE_DATASET_ROLE.sql
@@ -0,0 +1,33 @@
+use auth;
+
+SET @uuidRule = REPLACE(UUID(), '-', '');
+INSERT
+ INTO access_rule (
+ uuid, name, description, value,
+ rule, type, checkMapKeyOnly, checkMapNode, subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates
+ )
+ VALUES (
+ unhex(@uuidRule), 'SAVE_DATASET', 'Can only do /dataset', '/dataset/named',
+ ' $.[\'Target Service\']', 6, 0, 0, NULL, 0, 0
+ );
+
+SET @uuidPriv = REPLACE(UUID(), '-', '');
+INSERT
+ INTO privilege (
+ uuid, name,
+ description,
+ application_id
+ )
+ VALUES (
+ unhex(@uuidPriv), 'SAVE_DATASET',
+ 'Allow access to the /dataset/named/ function',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT
+ INTO accessRule_privilege ( privilege_id, accessRule_id )
+ VALUES ( unhex(@uuidPriv), unhex(@uuidRule) );
+
+INSERT
+ INTO role_privilege ( role_id, privilege_id )
+ VALUES ( (SELECT uuid FROM role WHERE name = 'PIC-SURE User'), unhex(@uuidPriv) );
diff --git a/GIC-Common-Area/auth/V21__UPDATE_CREATE_UUID_GEN_RULE.sql b/GIC-Common-Area/auth/V21__UPDATE_CREATE_UUID_GEN_RULE.sql
new file mode 100644
index 0000000..c56b4d1
--- /dev/null
+++ b/GIC-Common-Area/auth/V21__UPDATE_CREATE_UUID_GEN_RULE.sql
@@ -0,0 +1,3 @@
+use auth;
+
+UPDATE access_rule SET rule = "query.resourceUUID" WHERE name = "CREATE_UUID";
diff --git a/GIC-Common-Area/auth/V22__FIX_LEADING_SPACES.sql b/GIC-Common-Area/auth/V22__FIX_LEADING_SPACES.sql
new file mode 100644
index 0000000..73e7d67
--- /dev/null
+++ b/GIC-Common-Area/auth/V22__FIX_LEADING_SPACES.sql
@@ -0,0 +1,9 @@
+use auth;
+
+UPDATE access_rule
+ SET rule = '$.[\'Target Service\']'
+ WHERE name IN ('SAVE_DATASET', 'AR_ONLY_SEARCH', 'AR_ONLY_resource', 'AR_ONLY_info/resource', 'GATE_RESOURCE');
+
+UPDATE access_rule
+ SET rule = '$.[\'query\']'
+ WHERE name IN ('AR_RESOURCE_LIST');
diff --git a/GIC-Common-Area/auth/V2__CONFIGURE_PIC_SURE_APPLICATION.sql b/GIC-Common-Area/auth/V2__CONFIGURE_PIC_SURE_APPLICATION.sql
new file mode 100644
index 0000000..5adc841
--- /dev/null
+++ b/GIC-Common-Area/auth/V2__CONFIGURE_PIC_SURE_APPLICATION.sql
@@ -0,0 +1,27 @@
+use auth;
+INSERT INTO application VALUES (0x__APPLICATION_UUID__,'PIC-SURE multiple data access API',0x01,'PICSURE','','/picsureui');
+INSERT INTO `privilege` VALUES
+(0x7044061AF65B425F86CE73A1BF7F4402,'PIC-SURE Auth super admin for managing roles/privileges/application/connections','SUPER_ADMIN',NULL,'[]',NULL),
+(0xAD08212E096F414CBA8D1BAE09415DAB,'PIC-SURE Auth admin for managing users.','ADMIN',NULL,'[]',NULL);
+INSERT INTO `privilege` VALUES (0xF65B425F867044061ACE73A1BF7F4402,'User who cann run any PIC-SURE Query','PIC_SURE_ANY_QUERY',0x__APPLICATION_UUID__,'[]',NULL);
+INSERT INTO `role` VALUES (0x002DC366B0D8420F998F885D0ED797FD,'PIC-SURE Top Admin','PIC-SURE Auth Micro App Top admin including Admin and super Admin, can manage roles and privileges directly');
+INSERT INTO `role` VALUES (0x8F885D0ED797FD002DC366B0D8420F99,'Admin','Normal admin users, can manage other users including assignment of roles and privileges');
+INSERT INTO `role` VALUES (0x797FD002DC366B0D8420F998F885D0ED,'PIC-SURE User','Normal user, can run any query including data export.');
+INSERT INTO `connection` VALUES (0x97FD002DC366B0D8420F998F885D0ED7, 'Google', 'google-oauth2','google-oauth2|','[{"label":"Email", "id":"email"}]');
+INSERT INTO `connection` VALUES (0x97FB0D8420F998F885D0ED7D002DC366, 'BCH', 'ldap-connector','ad|ldap-connector|','[{"label":"BCH Email","id":"email"}]');
+INSERT INTO `connection` VALUES (0x97FD0F998F88002DC366B0D8425D0ED7, 'CCHMC', 'cchmc','samlp|cchmc|','[{"label":"CCHMC Email", "id":"email"}]');
+INSERT INTO `connection` VALUES (0x9766B0D8420F998F88FD002DC35D0ED7, 'CHOP', 'CHOP','samlp|CHOP|','[{"label":"CHOP Email", "id":"email"}]');
+INSERT INTO `connection` VALUES (0x976B0D8420F998F88FD002DC365D0ED7, 'PITT', 'pitt-edu','samlp|','[{"label":"PITT Email", "id":"email"}]');
+INSERT INTO `connection` VALUES (0x9B0D8420F7FD002DC366998F885D0ED7, 'WUSTL', 'wustl','samlp|wustl|','[{"label":"Washington University in St. Louis Email", "id":"email"}]');
+INSERT INTO `role_privilege` VALUES
+(0x002DC366B0D8420F998F885D0ED797FD,0x7044061AF65B425F86CE73A1BF7F4402),
+(0x002DC366B0D8420F998F885D0ED797FD,0xAD08212E096F414CBA8D1BAE09415DAB),
+(0x8F885D0ED797FD002DC366B0D8420F99,0xAD08212E096F414CBA8D1BAE09415DAB),
+(0x797FD002DC366B0D8420F998F885D0ED,0xF65B425F867044061ACE73A1BF7F4402);
+INSERT INTO `userMetadataMapping` VALUES
+(unhex('17FD002DC366B0D8420F998F885D0ED7'), '$.email', unhex('97FD002DC366B0D8420F998F885D0ED7'), '$.email'),
+(unhex('17FB0D8420F998F885D0ED7D002DC366'), '$.email', unhex('97FB0D8420F998F885D0ED7D002DC366'), '$.email'),
+(unhex('17FD0F998F88002DC366B0D8425D0ED7'), '$.email', unhex('97FD0F998F88002DC366B0D8425D0ED7'), '$.email'),
+(unhex('1766B0D8420F998F88FD002DC35D0ED7'), '$.email', unhex('9766B0D8420F998F88FD002DC35D0ED7'), '$.email'),
+(unhex('176B0D8420F998F88FD002DC365D0ED7'), '$.email', unhex('976B0D8420F998F88FD002DC365D0ED7'), '$.email'),
+(unhex('1B0D8420F7FD002DC366998F885D0ED7'), '$.email', unhex('9B0D8420F7FD002DC366998F885D0ED7'), '$.email');
diff --git a/GIC-Common-Area/auth/V3__CONFIGURE_JUPYTERHUB_APPLICATION.sql b/GIC-Common-Area/auth/V3__CONFIGURE_JUPYTERHUB_APPLICATION.sql
new file mode 100644
index 0000000..6c62d96
--- /dev/null
+++ b/GIC-Common-Area/auth/V3__CONFIGURE_JUPYTERHUB_APPLICATION.sql
@@ -0,0 +1,5 @@
+use auth;
+INSERT INTO application VALUES (0xDEADBEEFE9B1458594536ED31D456752,'JupyterHub authentication via PSAMA',0x01,'JupyterHub','','/jupyterhub');
+INSERT INTO `privilege` VALUES (0x530AF81BE8F744AB85E8222D0C743410,'JupyterHub user for accessing notebooks','JUPYTER_USER',0xDEADBEEFE9B1458594536ED31D456752,'[]',NULL);
+INSERT INTO `role` VALUES (0x7EF44B39239318D5B4C2D467580CE4E8,'JupyterHub User','The user is able to access JupyterHub as a normal user');
+INSERT INTO `role_privilege` VALUES (0x7EF44B39239318D5B4C2D467580CE4E8, 0x530AF81BE8F744AB85E8222D0C743410);
diff --git a/GIC-Common-Area/auth/V4__UPDATE_CCHMC_USER_METADATA_MAPPING.sql b/GIC-Common-Area/auth/V4__UPDATE_CCHMC_USER_METADATA_MAPPING.sql
new file mode 100644
index 0000000..d3dcb9a
--- /dev/null
+++ b/GIC-Common-Area/auth/V4__UPDATE_CCHMC_USER_METADATA_MAPPING.sql
@@ -0,0 +1 @@
+UPDATE userMetadataMapping SET auth0MetadataJsonPath='$.nameIdAttributes.value' WHERE uuid=unhex('17FD0F998F88002DC366B0D8425D0ED7');
diff --git a/GIC-Common-Area/auth/V5__CREATE_AGGREGATE_ACCESSRULE.sql b/GIC-Common-Area/auth/V5__CREATE_AGGREGATE_ACCESSRULE.sql
new file mode 100644
index 0000000..f2aa1b5
--- /dev/null
+++ b/GIC-Common-Area/auth/V5__CREATE_AGGREGATE_ACCESSRULE.sql
@@ -0,0 +1,49 @@
+use auth;
+
+INSERT INTO access_rule (uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode, subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates)
+ VALUES (unhex(REPLACE(uuid(),'-','')), 'HPDS Aggregate Counts', 'HPDS Counts', '$..expectedResultType', 4, 'COUNT', 0x00, 0x00, NULL, 0x00, 0x00);
+
+INSERT INTO access_rule (uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode, subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates)
+ VALUES (unhex(REPLACE(uuid(),'-','')), 'HPDS Aggregate Observation Counts', 'HPDS observation Counts', '$..expectedResultType', 4, 'OBSERVATION_COUNT', 0x00, 0x00, NULL, 0x00, 0x00);
+
+INSERT INTO access_rule (uuid, name, description, rule, type, value, checkMapKeyOnly, checkMapNode, subAccessRuleParent_uuid, isGateAnyRelation, isEvaluateOnlyByGates)
+ VALUES (unhex(REPLACE(uuid(),'-','')), 'HPDS Aggregate Observation Cross Counts', 'HPDS observation cross Counts', '$..expectedResultType', 4, 'OBSERVATION_CROSS_COUNT', 0x00, 0x00, NULL, 0x00, 0x00);
+
+
+INSERT INTO privilege (uuid, name, description, application_id)
+ VALUES (unhex(REPLACE(uuid(),'-','')),
+ 'AGGREGATE',
+ 'Aggregiate Data Sharing privilege for PICSURE application',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ (SELECT uuid FROM privilege WHERE name = 'AGGREGATE'),
+ (SELECT uuid FROM access_rule WHERE name = 'HPDS Aggregate Counts')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ (SELECT uuid FROM privilege WHERE name = 'AGGREGATE'),
+ (SELECT uuid FROM access_rule WHERE name = 'HPDS Aggregate Observation Counts')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ (SELECT uuid FROM privilege WHERE name = 'AGGREGATE'),
+ (SELECT uuid FROM access_rule WHERE name = 'HPDS Aggregate Observation Cross Counts')
+ );
+
+
+INSERT INTO role (uuid, name, description)
+ VALUES (unhex(REPLACE(uuid(),'-','')),
+ 'PIC-SURE Aggregate Count User',
+ 'PIC-SURE Aggregate Count User. Can perform aggregate count queries only.'
+ );
+
+INSERT INTO role_privilege (role_id, privilege_id)
+ VALUES (
+ (SELECT uuid FROM role WHERE name = 'PIC-SURE Aggregate Count User'),
+ (SELECT uuid FROM privilege WHERE name = 'AGGREGATE')
+ );
\ No newline at end of file
diff --git a/GIC-Common-Area/auth/V6__ADD_DEFAULT_ROLES.sql b/GIC-Common-Area/auth/V6__ADD_DEFAULT_ROLES.sql
new file mode 100644
index 0000000..5a4e3d3
--- /dev/null
+++ b/GIC-Common-Area/auth/V6__ADD_DEFAULT_ROLES.sql
@@ -0,0 +1,158 @@
+use auth;
+
+SET @uuidRule = REPLACE(UUID(),'-','');
+INSERT INTO access_rule VALUES (
+ unhex(@uuidRule),
+ 'AR_INFO_COLUMN_LISTING',
+ 'allow query to info_column_listing',
+ '$..expectedResultType',
+ 4,
+ 'INFO_COLUMN_LISTING',
+ 0,
+ 0,
+ NULL,
+ 0,
+ 0
+ );
+
+SET @uuidPriv = REPLACE(UUID(),'-','');
+INSERT INTO privilege (uuid, name, description, application_id)
+ VALUES ( unhex(@uuidPriv),
+ 'PRIV_INFO_COLUMN_LISTING',
+ 'Allow access to variant info metadata',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ unhex(@uuidPriv),
+ unhex(@uuidRule)
+ );
+
+
+ SET @uuidRole = REPLACE(UUID(),'-','');
+ INSERT INTO role VALUES (
+ unhex(@uuidRole),
+ 'INFO_COLUMN_LISTING',
+ 'Allow access to info column metadata'
+ );
+
+INSERT INTO role_privilege (role_id, privilege_id)
+ VALUES (
+ unhex(@uuidRole),
+ unhex(@uuidPriv)
+ );
+
+
+
+SET @uuidRule = REPLACE(UUID(),'-','');
+INSERT INTO access_rule VALUES (
+ unhex(@uuidRule),
+ 'AR_ONLY_SEARCH',
+ 'Can only do /search',
+ ' $.[\'Target Service\']',
+ 6,
+ '/search',
+ 0,
+ 0,
+ NULL,
+ 0,
+ 0
+ );
+
+SET @uuidPriv = REPLACE(UUID(),'-','');
+INSERT INTO privilege (uuid, name, description, application_id)
+ VALUES ( unhex(@uuidPriv),
+ 'PRIV_ONLY_SEARCH',
+ 'Allow access to the /search/ function',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ unhex(@uuidPriv),
+ unhex(@uuidRule)
+ );
+
+
+ SET @uuidRole = REPLACE(UUID(),'-','');
+ INSERT INTO role VALUES (
+ unhex(@uuidRole),
+ 'SEARCH_ONLY',
+ 'Allow access to the /search/ function'
+ );
+
+INSERT INTO role_privilege (role_id, privilege_id)
+ VALUES (
+ unhex(@uuidRole),
+ unhex(@uuidPriv)
+ );
+
+
+
+
+SET @uuidRule = REPLACE(UUID(),'-','');
+INSERT INTO access_rule VALUES (
+ unhex(@uuidRule),
+ 'AR_ONLY_resource',
+ 'Can only access /resource',
+ ' $.[\'Target Service\']',
+ 6,
+ '/resource',
+ 0,
+ 0,
+ NULL,
+ 0,
+ 0
+ );
+
+SET @uuidPriv = REPLACE(UUID(),'-','');
+INSERT INTO privilege (uuid, name, description, application_id)
+ VALUES ( unhex(@uuidPriv),
+ 'PRIV_ONLY_RESOURCES',
+ 'Allow access to the /info/resources and /resource functions',
+ (SELECT uuid FROM application WHERE name = 'PICSURE')
+ );
+
+INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ unhex(@uuidPriv),
+ unhex(@uuidRule)
+ );
+
+
+
+SET @uuidRule = REPLACE(UUID(),'-','');
+INSERT INTO access_rule VALUES (
+ unhex(@uuidRule),
+ 'AR_ONLY_info/resource',
+ 'Can only access /info/resources',
+ ' $.[\'Target Service\']',
+ 6,
+ '/info/resources',
+ 0,
+ 0,
+ NULL,
+ 0,
+ 0
+ );
+
+ INSERT INTO accessRule_privilege (privilege_id, accessRule_id)
+ VALUES (
+ unhex(@uuidPriv),
+ unhex(@uuidRule)
+ );
+
+
+ SET @uuidRole = REPLACE(UUID(),'-','');
+ INSERT INTO role VALUES (
+ unhex(@uuidRole),
+ 'RESOURCES_ONLY',
+ 'Allow access to the /info/resources and /resource function'
+ );
+
+INSERT INTO role_privilege (role_id, privilege_id)
+ VALUES (
+ unhex(@uuidRole),
+ unhex(@uuidPriv)
+ );
diff --git a/GIC-Common-Area/auth/V7__ADD_TERMS_OF_SERVICE.sql b/GIC-Common-Area/auth/V7__ADD_TERMS_OF_SERVICE.sql
new file mode 100644
index 0000000..4a3d05b
--- /dev/null
+++ b/GIC-Common-Area/auth/V7__ADD_TERMS_OF_SERVICE.sql
@@ -0,0 +1,28 @@
+use auth;
+
+INSERT INTO termsOfService (uuid, dateUpdated, content)
+ VALUES (UNHEX(REPLACE(uuid(),'-','')), CURRENT_TIMESTAMP(),
+ '
+
+
+
Terms and Conditions of Use of the Genomic Information Commons (GIC) Portal
+
+
+
User must select the terms and click “accept” to certify that User agrees to the Terms and Conditions of Use of the GIC Portal: