Skip to content

Commit

Permalink
Merge pull request #64 from ga4gh/feature/batch-request
Browse files Browse the repository at this point in the history
batch requests, auth info, passport-mediated auth
  • Loading branch information
Jeremy Adams authored May 19, 2022
2 parents c161eb5 + 8e67094 commit 584cee6
Show file tree
Hide file tree
Showing 34 changed files with 1,071 additions and 334 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ repositories {
}

dependencies {
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'

implementation 'com.google.guava:guava:28.1-jre'
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.0'
implementation 'commons-cli:commons-cli:1.4'
Expand All @@ -62,8 +65,12 @@ dependencies {
implementation 'javax.xml.bind:jaxb-api:2.2.8'
implementation 'org.springdoc:springdoc-openapi-ui:1.2.33'
implementation 'org.xerial:sqlite-jdbc:3.8.11.2'
implementation 'com.auth0:java-jwt:3.19.1'
implementation 'org.ga4gh:ga4gh-starter-kit-common:0.5.6'

testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'

testImplementation 'org.testng:testng:7.0.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.0'
testImplementation 'org.springframework.security:spring-security-test'
Expand Down
110 changes: 110 additions & 0 deletions database/sqlite/add-dev-dataset.sql
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,113 @@ INSERT INTO drs_object_bundle VALUES
("355a74bd-6571-4d4a-8602-a9989936717f", "8f40acc0-0c54-45c5-8c85-a6f5fb32a1a7"),
("355a74bd-6571-4d4a-8602-a9989936717f", "41898242-62a9-4129-9a2c-5a4e8f5f0afb"),
("355a74bd-6571-4d4a-8602-a9989936717f", "6b994f18-6189-4233-bb83-139686490d68");

/* MINI DATASET FOR PASSPORTS AUTH */

INSERT INTO passport_broker VALUES (
'https://ga4gh.org/',
'insecureSecretPleaseOverride'
);

INSERT INTO passport_visa VALUES
(
0,
'StarterKitDatasetsControlledAccessGrants',
'https://datasets.starterkit.ga4gh.org/',
'87A3B5D68FD88197254D9889B4AAB',
'https://ga4gh.org/'
);

INSERT INTO drs_object (
id,
description,
created_time,
mime_type,
name,
size,
updated_time,
version,
is_bundle
) VALUES
(
"e26f8428-1a5d-4465-b389-10998ba7b894",
"PASSPORT AUTH - Phenopackets, Cao Patient 1",
"2022-05-16 20:00:00.000",
"application/json",
"passport.phenopackets.cao.1",
4257,
"2022-05-16 20:00:00.000",
"1.0.0",
0
),
(
"996ead07-8dfc-4c5d-b319-5b59bebb507e",
"PASSPORT AUTH - Phenopackets, Cao Patient 2",
"2022-05-16 20:00:00.000",
"application/json",
"passport.phenopackets.cao.2",
7401,
"2022-05-16 20:00:00.000",
"1.0.0",
0
),
(
"81e8b499-1054-4846-8df4-d079ea32a44f",
"PASSPORT AUTH - Phenopackets, Cao Patient 3",
"2022-05-16 20:00:00.000",
"application/json",
"passport.phenopackets.cao.3",
4251,
"2022-05-16 20:00:00.000",
"1.0.0",
0
),
(
"672d0425-137c-437f-ab12-29a3cce1ffc0",
"PASSPORT AUTH - Phenopackets, Cao Patient 4",
"2022-05-16 20:00:00.000",
"application/json",
"passport.phenopackets.cao.4",
9264,
"2022-05-16 20:00:00.000",
"1.0.0",
0
);

INSERT INTO drs_object_alias VALUES
("e26f8428-1a5d-4465-b389-10998ba7b894", "Passport-Cao-FBN1-1"),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", "Passport-Cao-FBN1-2"),
("81e8b499-1054-4846-8df4-d079ea32a44f", "Passport-Cao-FBN1-3"),
("672d0425-137c-437f-ab12-29a3cce1ffc0", "Passport-Cao-TGFBR2-4");

INSERT INTO drs_object_checksum (drs_object_id, checksum, type) VALUES
("e26f8428-1a5d-4465-b389-10998ba7b894", "f81ea43c74824cc72c77a39a92bf7b71", "md5"),
("e26f8428-1a5d-4465-b389-10998ba7b894", "34880a6b8aa517a6999da912614753ffb0a837a8", "sha1"),
("e26f8428-1a5d-4465-b389-10998ba7b894", "ec44e2ad7ec84c7c42ba57b205e67c7c7416ae1932029d8364cc053cef7abe58", "sha256"),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", "1cbab050aa20410dc14ce6906f0312fa", "md5"),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", "3f2f2133054faf71ca9d678fa1fd8918a521faec", "sha1"),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", "2709878797b4e8c6a7db824fa596f42885551cef730d1408b2b620c9eee43089", "sha256"),
("81e8b499-1054-4846-8df4-d079ea32a44f", "45b61bbe53b13463cd602081613ad855", "md5"),
("81e8b499-1054-4846-8df4-d079ea32a44f", "d3192e17ffd97f7255ffbe2c6f9b447568107612", "sha1"),
("81e8b499-1054-4846-8df4-d079ea32a44f", "f60583aad0e25fc4805668663bcc3bef271f4f93ee98be4f57f6e8c3e26d9dba", "sha256"),
("672d0425-137c-437f-ab12-29a3cce1ffc0", "7d3b0a967215523c29de61baff26bfa2", "md5"),
("672d0425-137c-437f-ab12-29a3cce1ffc0", "ae6c744487ddf785976893d1bdce2f81c017921e", "sha1"),
("672d0425-137c-437f-ab12-29a3cce1ffc0", "69dd919e14d162ebd0132a395cf1967346fd203210428287c354b11eebdda8b3", "sha256");

INSERT INTO file_access_object (drs_object_id, path) VALUES
("e26f8428-1a5d-4465-b389-10998ba7b894", "./src/test/resources/data/phenopackets/Cao-2018-FBN1-Patient_1.json"),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", "./src/test/resources/data/phenopackets/Cao-2018-FBN1-Patient_2.json"),
("81e8b499-1054-4846-8df4-d079ea32a44f", "./src/test/resources/data/phenopackets/Cao-2018-FBN1-Patient_3.json"),
("672d0425-137c-437f-ab12-29a3cce1ffc0", "./src/test/resources/data/phenopackets/Cao-2018-TGFBR2-Patient_4.json");

INSERT INTO aws_s3_access_object (drs_object_id, region, bucket, key) VALUES
("e26f8428-1a5d-4465-b389-10998ba7b894", "us-east-2", "ga4gh-demo-data", "/phenopackets/Cao-2018-FBN1-Patient_1.json"),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", "us-east-2", "ga4gh-demo-data", "/phenopackets/Cao-2018-FBN1-Patient_2.json"),
("81e8b499-1054-4846-8df4-d079ea32a44f", "us-east-2", "ga4gh-demo-data", "/phenopackets/Cao-2018-FBN1-Patient_3.json"),
("672d0425-137c-437f-ab12-29a3cce1ffc0", "us-east-2", "ga4gh-demo-data", "/phenopackets/Cao-2018-TGFBR2-Patient_4.json");

INSERT INTO drs_object_visa VALUES
("e26f8428-1a5d-4465-b389-10998ba7b894", 0),
("996ead07-8dfc-4c5d-b319-5b59bebb507e", 0),
("81e8b499-1054-4846-8df4-d079ea32a44f", 0),
("672d0425-137c-437f-ab12-29a3cce1ffc0", 0);
21 changes: 21 additions & 0 deletions database/sqlite/create-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,24 @@ CREATE TABLE drs_object_bundle (
FOREIGN KEY(parent_id) REFERENCES drs_object(id),
FOREIGN KEY(child_id) REFERENCES drs_object(id)
);

CREATE TABLE passport_broker (
url TEXT PRIMARY KEY,
secret TEXT
);

CREATE TABLE passport_visa (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
issuer TEXT,
secret TEXT,
passport_broker_url TEXT,
FOREIGN KEY (passport_broker_url) REFERENCES passport_broker(url)
);

CREATE TABLE drs_object_visa (
drs_object_id TEXT,
visa_id TEXT,
FOREIGN KEY(drs_object_id) REFERENCES drs_object(id),
FOREIGN KEY(visa_id) REFERENCES passport_visa(id)
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import org.ga4gh.starterkit.drs.model.DrsObject;
import org.ga4gh.starterkit.drs.model.DrsServiceInfo;
import org.ga4gh.starterkit.drs.model.FileAccessObject;
import org.ga4gh.starterkit.drs.model.PassportBroker;
import org.ga4gh.starterkit.drs.model.PassportVisa;
import org.ga4gh.starterkit.drs.utils.cache.AccessCache;
import org.ga4gh.starterkit.drs.utils.hibernate.DrsHibernateUtil;
import org.ga4gh.starterkit.drs.utils.passport.UserPassportMapVerifier;
import org.ga4gh.starterkit.drs.utils.requesthandler.AccessRequestHandler;
import org.ga4gh.starterkit.drs.utils.requesthandler.AuthInfoRequestHandler;
import org.ga4gh.starterkit.drs.utils.requesthandler.FileStreamRequestHandler;
import org.ga4gh.starterkit.drs.utils.requesthandler.ObjectRequestHandler;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -232,6 +236,8 @@ public List<Class<? extends HibernateEntity<? extends Serializable>>> getAnnotat
annotatedClasses.add(Checksum.class);
annotatedClasses.add(FileAccessObject.class);
annotatedClasses.add(AwsS3AccessObject.class);
annotatedClasses.add(PassportBroker.class);
annotatedClasses.add(PassportVisa.class);
return annotatedClasses;
}

Expand Down Expand Up @@ -261,7 +267,7 @@ public DrsHibernateUtil getDrsHibernateUtil(
* @return drs object request handler
*/
@Bean
@RequestScope
@Scope(DrsServerConstants.PROTOTYPE)
public ObjectRequestHandler objectRequestHandler() {
return new ObjectRequestHandler();
}
Expand All @@ -277,6 +283,12 @@ public AccessRequestHandler accessRequestHandler() {
return new AccessRequestHandler();
}

@Bean
@RequestScope
public AuthInfoRequestHandler authInfoRequestHandler() {
return new AuthInfoRequestHandler();
}

/**
* Get new request handler facilitating streaming of a local file over http(s)
* @return streaming request handler
Expand All @@ -299,4 +311,9 @@ public FileStreamRequestHandler fileStreamRequestHandler() {
public AccessCache accessCache() {
return new AccessCache();
}

@Bean
public UserPassportMapVerifier userPAssportMapVerifier() {
return new UserPassportMapVerifier();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,6 @@ private void breakInterminableFetch(DrsObject drsObject) {
drsObject.setAwsS3AccessObjects(null);
drsObject.setDrsObjectChildren(null);
drsObject.setDrsObjectParents(null);
drsObject.setPassportVisas(null);
}
}
Loading

0 comments on commit 584cee6

Please sign in to comment.