From d15e3617ea772f9a95d5d07f1aa89ecc7b96104f Mon Sep 17 00:00:00 2001 From: DerDavidBohl Date: Thu, 2 Oct 2025 16:45:05 +0200 Subject: [PATCH] Added Secret Deletion --- .../org/davidbohl/dirigent/sercrets/SecretController.java | 6 ++++++ .../java/org/davidbohl/dirigent/sercrets/SecretService.java | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretController.java b/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretController.java index a78f4a9..50ac049 100644 --- a/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretController.java +++ b/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretController.java @@ -2,6 +2,7 @@ package org.davidbohl.dirigent.sercrets; import java.util.List; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PutMapping; @@ -28,6 +29,11 @@ public class SecretController { this.secretService.saveSecret(key, secret.environmentVariable(), secret.value(), secret.deployments()); } + @DeleteMapping("{key}") + public void deleteSecret(@PathVariable String key) { + this.secretService.deleteSecret(key); + } + @GetMapping public List getSecrets() { return this.secretService.getAllSecretsWithoutValues(); diff --git a/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretService.java b/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretService.java index 9914a31..7e76fde 100644 --- a/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretService.java +++ b/backend/src/main/java/org/davidbohl/dirigent/sercrets/SecretService.java @@ -66,6 +66,10 @@ public class SecretService { ).toList(); } + public void deleteSecret(String key) { + secretRepository.deleteById(key); + } + private String encrypt(String value) throws Exception { SecretKeySpec keySpec = new SecretKeySpec(encryptionKey.getBytes(), ALGORITHM); Cipher cipher = Cipher.getInstance(ALGORITHM);