From 7021366e17271a926a82d666c49af616573b19fe Mon Sep 17 00:00:00 2001 From: Dwayne Jeng Date: Thu, 11 Jan 2024 12:14:09 -0800 Subject: [PATCH] DefaultAppBootstrapper to create worker account (wip) --- .../bridge/DefaultAppBootstrapper.java | 12 ++++++++++++ src/main/resources/BridgeServer2.conf | 12 +++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/sagebionetworks/bridge/DefaultAppBootstrapper.java b/src/main/java/org/sagebionetworks/bridge/DefaultAppBootstrapper.java index bbb8cb6d9..fcc97ffc4 100644 --- a/src/main/java/org/sagebionetworks/bridge/DefaultAppBootstrapper.java +++ b/src/main/java/org/sagebionetworks/bridge/DefaultAppBootstrapper.java @@ -7,6 +7,7 @@ import static org.sagebionetworks.bridge.BridgeConstants.TEST_USER_GROUP; import static org.sagebionetworks.bridge.Roles.ADMIN; import static org.sagebionetworks.bridge.Roles.SUPERADMIN; +import static org.sagebionetworks.bridge.Roles.WORKER; import static org.sagebionetworks.bridge.config.Environment.PROD; import static org.sagebionetworks.bridge.models.accounts.SharingScope.NO_SHARING; @@ -134,6 +135,17 @@ public void onApplicationEvent(ContextRefreshedEvent event) { if (bootstrapUserConfigured && bridgeConfig.getEnvironment() != Environment.PROD) { createAccount(shared, admin); } + + // Make worker account. + String workerEmail = bridgeConfig.get("worker.email"); + String workerPassword = bridgeConfig.get("worker.password"); + if (workerEmail != null && workerPassword != null) { + Account worker = Account.create(); + worker.setEmail(workerEmail); + worker.setPassword(workerPassword); + worker.setRoles(Sets.newHashSet(WORKER)); + createAccount(app, worker); + } } private App createApp(String appId, String name, Consumer consumer) { diff --git a/src/main/resources/BridgeServer2.conf b/src/main/resources/BridgeServer2.conf index 8120d1b52..5feb9e26d 100644 --- a/src/main/resources/BridgeServer2.conf +++ b/src/main/resources/BridgeServer2.conf @@ -168,12 +168,14 @@ usersigned.consents.bucket = org-sagebridge-usersigned-consents-${bucket.suffix} prod.usersigned.consents.bucket = bridgepf-prod-awss3usersignedconsentsdownloadbuck-1slz1bcz0mls7 # Bootstrap user for integration tests (will only be used when first initializing your database). -# This should match the synapse.test.user.* credentials set for your integration test properties +# This should match the synapse.test.user.* credentials set for your integration test properties # in your bridge-sdk-test.properties file. admin.email = dummy-value admin.password = dummy-value admin.synapse.user.id = 3336429 prod.admin.synapse.user.id = 3399057 +worker.email = dummy-value +worker.password = dummy-value synapse.oauth.url = https://repo-dev.dev.sagebase.org/auth/v1/oauth2/token prod.synapse.oauth.url = https://repo-prod.prod.sagebase.org/auth/v1/oauth2/token @@ -199,7 +201,7 @@ gbf.order.returns.url = https://www.gbfmedical.com/oap/api/returns gbf.ship.confirmation.url = https://www.gbfmedical.com/oap/api/confirm gbf.api.key = dummy-value -# Schedule timeline metadata records batch persist. Values above 100 do not seem to +# Schedule timeline metadata records batch persist. Values above 100 do not seem to # improve performance, but values under 100 start to degrade it a bit. schedule.batch.size = 100 @@ -237,9 +239,9 @@ participantroster.bucket = org-sagebridge-participantroster-${bucket.suffix} # Public documents folder docs.bucket = docs${host.postfix} -# In production, the bucket name and domain name are the same because we can configure -# the domain name in Route 53. In local, development, and staging environments, we do -# not (can not?) configure DNS entries because they are in a separate AWS account. +# In production, the bucket name and domain name are the same because we can configure +# the domain name in Route 53. In local, development, and staging environments, we do +# not (can not?) configure DNS entries because they are in a separate AWS account. # So we use the full S3 website hosting URL. docs.website.url = ${docs.bucket} local.docs.website.url = docs-${bridge.user}.sagebridge.org.s3-website-us-east-1.amazonaws.com