summaryrefslogtreecommitdiffstats
path: root/sms-service
diff options
context:
space:
mode:
Diffstat (limited to 'sms-service')
-rw-r--r--sms-service/src/sms/backend/vault.go14
-rw-r--r--sms-service/src/sms/handler/handler.go6
2 files changed, 18 insertions, 2 deletions
diff --git a/sms-service/src/sms/backend/vault.go b/sms-service/src/sms/backend/vault.go
index 7fc1747..259b4f3 100644
--- a/sms-service/src/sms/backend/vault.go
+++ b/sms-service/src/sms/backend/vault.go
@@ -153,7 +153,7 @@ func (v *Vault) CreateSecret(dom string, sec Secret) error {
dom = v.vaultMount + "/" + dom
- // Vault write return is empty on successful write
+ // Vault return is empty on successful write
_, err = v.vaultClient.Logical().Write(dom+"/"+sec.Name, sec.Values)
if err != nil {
return errors.New("Unable to create Secret at provided path")
@@ -171,6 +171,18 @@ func (v *Vault) DeleteSecretDomain(name string) error {
// DeleteSecret deletes a secret mounted on the path provided
func (v *Vault) DeleteSecret(dom string, name string) error {
+ err := v.checkToken()
+ if err != nil {
+ return errors.New("Token checking returned an error" + err.Error())
+ }
+
+ dom = v.vaultMount + "/" + dom
+
+ // Vault return is empty on successful delete
+ _, err = v.vaultClient.Logical().Delete(dom + "/" + name)
+ if err != nil {
+ return errors.New("Unable to delete Secret at provided path")
+ }
return nil
}
diff --git a/sms-service/src/sms/handler/handler.go b/sms-service/src/sms/handler/handler.go
index 3798023..e9c7eab 100644
--- a/sms-service/src/sms/handler/handler.go
+++ b/sms-service/src/sms/handler/handler.go
@@ -121,7 +121,11 @@ func (h handler) deleteSecretHandler(w http.ResponseWriter, r *http.Request) {
domName := vars["domName"]
secName := vars["secretName"]
- h.secretBackend.DeleteSecret(domName, secName)
+ err := h.secretBackend.DeleteSecret(domName, secName)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
// struct that tracks various status items for SMS and backend