diff --git a/src/main/java/com/uid2/admin/cloudencryption/CloudEncryptionKeyManager.java b/src/main/java/com/uid2/admin/cloudencryption/CloudEncryptionKeyManager.java index 819e9e65f..30aa7eb12 100644 --- a/src/main/java/com/uid2/admin/cloudencryption/CloudEncryptionKeyManager.java +++ b/src/main/java/com/uid2/admin/cloudencryption/CloudEncryptionKeyManager.java @@ -6,6 +6,7 @@ import com.uid2.shared.auth.RotatingOperatorKeyProvider; import com.uid2.shared.model.CloudEncryptionKey; import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider; +import io.vertx.core.json.JsonObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +35,15 @@ public CloudEncryptionKeyManager( this.planner = planner; } + public JsonObject getMetadata() throws Exception { + return keyProvider.getMetadata(); + } + + public Set getKeySummaries() throws Exception { + refreshCloudData(); + return existingKeys.stream().map(CloudEncryptionKeySummary::fromFullKey).collect(Collectors.toSet()); + } + // For any site that has an operator create a new key activating in one hour // Keep up to 10 most recent old keys per site, delete the rest public void rotateKeys(boolean shouldFail) throws Exception { @@ -66,11 +76,6 @@ public void backfillKeys() throws Exception { } } - public Set getKeySummaries() throws Exception { - refreshCloudData(); - return existingKeys.stream().map(CloudEncryptionKeySummary::fromFullKey).collect(Collectors.toSet()); - } - private void writeKeys(Set desiredKeys) throws Exception { var keysForWriting = desiredKeys.stream().collect(Collectors.toMap( CloudEncryptionKey::getId, @@ -85,4 +90,4 @@ private void refreshCloudData() throws Exception { operatorKeys = new HashSet<>(operatorKeyProvider.getAll()); existingKeys = new HashSet<>(keyProvider.getAll().values()); } -} \ No newline at end of file +} diff --git a/src/main/java/com/uid2/admin/vertx/Endpoints.java b/src/main/java/com/uid2/admin/vertx/Endpoints.java index 4464d9037..b7045bb5c 100644 --- a/src/main/java/com/uid2/admin/vertx/Endpoints.java +++ b/src/main/java/com/uid2/admin/vertx/Endpoints.java @@ -98,6 +98,7 @@ public enum Endpoints { API_SITE_APP_NAMES("/api/site/app_names"), API_SITE_UPDATE("/api/site/update"), + CLOUD_ENCRYPTION_KEY_METADATA("/api/cloud-encryption-key/metadata"), CLOUD_ENCRYPTION_KEY_LIST("/api/cloud-encryption-key/list"), CLOUD_ENCRYPTION_KEY_ROTATE("/api/cloud-encryption-key/rotate"), diff --git a/src/main/java/com/uid2/admin/vertx/service/CloudEncryptionKeyService.java b/src/main/java/com/uid2/admin/vertx/service/CloudEncryptionKeyService.java index 31f93292e..58ce50dd8 100644 --- a/src/main/java/com/uid2/admin/vertx/service/CloudEncryptionKeyService.java +++ b/src/main/java/com/uid2/admin/vertx/service/CloudEncryptionKeyService.java @@ -31,6 +31,9 @@ public CloudEncryptionKeyService( @Override public void setupRoutes(Router router) { + router.get(Endpoints.CLOUD_ENCRYPTION_KEY_METADATA.toString()).handler( + auth.handle(this::handleMetadata, Role.MAINTAINER)); + router.get(Endpoints.CLOUD_ENCRYPTION_KEY_LIST.toString()).handler( auth.handle(this::handleList, Role.MAINTAINER) ); @@ -40,6 +43,25 @@ public void setupRoutes(Router router) { ); } + private void handleMetadata(RoutingContext rc) { + try { + rc.response() + .putHeader(HttpHeaders.CONTENT_TYPE, "application/json") + .end(keyManager.getMetadata().encode()); + } catch (Exception e) { + rc.fail(500, e); + } + } + + private void handleList(RoutingContext rc) { + try { + var response = new CloudEncryptionKeyListResponse(keyManager.getKeySummaries()); + respondWithJson(rc, response); + } catch (Exception e) { + rc.fail(500, e); + } + } + private void handleRotate(RoutingContext rc) { try { var shouldFail = !rc.queryParam("fail").isEmpty(); @@ -59,15 +81,6 @@ private void handleRotate(RoutingContext rc) { } } - private void handleList(RoutingContext rc) { - try { - var response = new CloudEncryptionKeyListResponse(keyManager.getKeySummaries()); - respondWithJson(rc, response); - } catch (Exception e) { - rc.fail(500, e); - } - } - private static void respondWithJson(RoutingContext rc, CloudEncryptionKeyListResponse response) throws JsonProcessingException { rc.response() .putHeader(HttpHeaders.CONTENT_TYPE, "application/json") diff --git a/src/main/java/com/uid2/admin/vertx/service/EncryptedFilesSyncService.java b/src/main/java/com/uid2/admin/vertx/service/EncryptedFilesSyncService.java index 1a562b0da..3c5a6624a 100644 --- a/src/main/java/com/uid2/admin/vertx/service/EncryptedFilesSyncService.java +++ b/src/main/java/com/uid2/admin/vertx/service/EncryptedFilesSyncService.java @@ -33,7 +33,7 @@ public EncryptedFilesSyncService( this.jobDispatcher = jobDispatcher; this.writeLock = writeLock; this.config = config; - this.cloudEncryptionKeyProvider =cloudEncryptionKeyProvider; + this.cloudEncryptionKeyProvider = cloudEncryptionKeyProvider; } @Override diff --git a/src/test/java/com/uid2/admin/auth/OktaAuthFactoryTest.java b/src/test/java/com/uid2/admin/auth/OktaAuthProviderTest.java similarity index 98% rename from src/test/java/com/uid2/admin/auth/OktaAuthFactoryTest.java rename to src/test/java/com/uid2/admin/auth/OktaAuthProviderTest.java index fddb36437..14705f5c0 100644 --- a/src/test/java/com/uid2/admin/auth/OktaAuthFactoryTest.java +++ b/src/test/java/com/uid2/admin/auth/OktaAuthProviderTest.java @@ -2,7 +2,6 @@ import io.vertx.core.Vertx; import io.vertx.core.json.JsonObject; -import io.vertx.ext.auth.oauth2.OAuth2Auth; import io.vertx.ext.web.Route; import io.vertx.ext.web.handler.AuthenticationHandler; import io.vertx.ext.web.handler.impl.OAuth2AuthHandlerImpl; diff --git a/webroot/adm/client-side-keypairs.html b/webroot/adm/client-side-keypair.html similarity index 100% rename from webroot/adm/client-side-keypairs.html rename to webroot/adm/client-side-keypair.html diff --git a/webroot/adm/cloud-encryption-key.html b/webroot/adm/cloud-encryption-key.html new file mode 100644 index 000000000..cc4e9ecfe --- /dev/null +++ b/webroot/adm/cloud-encryption-key.html @@ -0,0 +1,160 @@ + + + + + + + + + +

UID2 Env - Cloud Encryption Key Management

+ +Back + +
+
+ + + + + + diff --git a/webroot/adm/keysets.html b/webroot/adm/keyset.html similarity index 100% rename from webroot/adm/keysets.html rename to webroot/adm/keyset.html diff --git a/webroot/adm/service-links.html b/webroot/adm/service-link.html similarity index 100% rename from webroot/adm/service-links.html rename to webroot/adm/service-link.html diff --git a/webroot/adm/services.html b/webroot/adm/service.html similarity index 100% rename from webroot/adm/services.html rename to webroot/adm/service.html diff --git a/webroot/index.html b/webroot/index.html index ac8627ec0..5bed5a052 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -7,52 +7,76 @@

UID2 Env Admin Site

- - - -
- - - - - - -
- + + +