diff options
Diffstat (limited to 'sms-service')
-rw-r--r-- | sms-service/src/sms/backend/vault.go | 14 | ||||
-rw-r--r-- | sms-service/src/sms/handler/handler.go | 6 |
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 bfc3367..6b9ad94 100644 --- a/sms-service/src/sms/backend/vault.go +++ b/sms-service/src/sms/backend/vault.go @@ -186,7 +186,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") @@ -204,6 +204,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 5fdbf3b..f5a0a0d 100644 --- a/sms-service/src/sms/handler/handler.go +++ b/sms-service/src/sms/handler/handler.go @@ -139,7 +139,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 |