Added Secret Deletion

This commit is contained in:
DerDavidBohl
2025-10-02 16:45:05 +02:00
parent a2f34b837d
commit d15e3617ea
2 changed files with 10 additions and 0 deletions

View File

@@ -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<SecretDto> getSecrets() {
return this.secretService.getAllSecretsWithoutValues();

View File

@@ -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);