Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rid of direct S3 access #157

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@
<artifactId>loki-logback-appender</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.368</version>
</dependency>
<dependency>
<groupId>com.iabtcf</groupId>
<artifactId>iabtcf-decoder</artifactId>
Expand Down
48 changes: 21 additions & 27 deletions src/main/java/com/uid2/operator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,48 +87,42 @@ public Main(Vertx vertx, JsonObject config) throws Exception {
}

boolean useStorageMock = config.getBoolean(Const.Config.StorageMockProp, false);
String coreAttestUrl = this.config.getString(Const.Config.CoreAttestUrlProp);
DownloadCloudStorage fsStores;
if (coreAttestUrl != null) {

DownloadCloudStorage contentStorage;
if (useStorageMock) {
LOGGER.info("Salt/Key/Client stores - Using EmbeddedResourceStorage");
contentStorage = new EmbeddedResourceStorage(Main.class);
this.fsOptOut = configureMockOptOutStore();
} else {
String coreAttestUrl = this.config.getString(Const.Config.CoreAttestUrlProp);
if (coreAttestUrl == null) {
throw new Exception("Missing configuration: " + Const.Config.CoreAttestUrlProp);
}
String coreApiToken = this.config.getString(Const.Config.CoreApiTokenProp);
UidCoreClient coreClient = createUidCoreClient(coreAttestUrl, coreApiToken);
fsStores = coreClient;
contentStorage = coreClient;
LOGGER.info("Salt/Key/Client stores - Using uid2-core attestation endpoint: " + coreAttestUrl);

Duration disableWaitTime = Duration.ofHours(this.config.getInteger(Const.Config.FailureShutdownWaitHoursProp, 120));
Duration disableWaitTime = Duration.ofHours(this.config.getInteger(
Const.Config.FailureShutdownWaitHoursProp,
120));
this.disableHandler = new OperatorDisableHandler(disableWaitTime, Clock.systemUTC());
coreClient.setResponseStatusWatcher(this.disableHandler::handleResponseStatus);

if (useStorageMock) {
this.fsOptOut = configureMockOptOutStore();
} else {
this.fsOptOut = configureAttestedOptOutStore(coreClient, coreAttestUrl);
}
} else if (useStorageMock) {
fsStores = new EmbeddedResourceStorage(Main.class);
LOGGER.info("Salt/Key/Client stores - Using EmbeddedResourceStorage");

this.fsOptOut = configureMockOptOutStore();
} else {
String coreBucket = this.config.getString(Const.Config.CoreS3BucketProp);
fsStores = CloudUtils.createStorage(coreBucket, config);
LOGGER.info("Salt/Key/Client stores - Using the same storage as optout: s3://" + coreBucket);

this.fsOptOut = configureCloudOptOutStore();
this.fsOptOut = configureAttestedOptOutStore(coreClient, coreAttestUrl);
}

String clientsMdPath = this.config.getString(Const.Config.ClientsMetadataPathProp);
this.clientKeyProvider = new RotatingClientKeyProvider(fsStores, new GlobalScope(new CloudPath(clientsMdPath)));
this.clientKeyProvider = new RotatingClientKeyProvider(contentStorage, new GlobalScope(new CloudPath(clientsMdPath)));
String keysMdPath = this.config.getString(Const.Config.KeysMetadataPathProp);
this.keyStore = new RotatingKeyStore(fsStores, new GlobalScope(new CloudPath(keysMdPath)));
this.keyStore = new RotatingKeyStore(contentStorage, new GlobalScope(new CloudPath(keysMdPath)));
String keysAclMdPath = this.config.getString(Const.Config.KeysAclMetadataPathProp);
this.keyAclProvider = new RotatingKeyAclProvider(fsStores, new GlobalScope(new CloudPath(keysAclMdPath)));
this.keyAclProvider = new RotatingKeyAclProvider(contentStorage, new GlobalScope(new CloudPath(keysAclMdPath)));
String saltsMdPath = this.config.getString(Const.Config.SaltsMetadataPathProp);
this.saltProvider = new RotatingSaltProvider(fsStores, saltsMdPath);
this.saltProvider = new RotatingSaltProvider(contentStorage, saltsMdPath);

this.optOutStore = new CloudSyncOptOutStore(vertx, fsLocal, this.config);

if (useStorageMock && coreAttestUrl == null) {
if (useStorageMock) {
this.clientKeyProvider.loadContent();
this.keyStore.loadContent();
this.keyAclProvider.loadContent();
Expand Down