summaryrefslogtreecommitdiffstats
path: root/sms-service
diff options
context:
space:
mode:
Diffstat (limited to 'sms-service')
-rw-r--r--sms-service/src/sms/backend/vault.go12
-rw-r--r--sms-service/src/sms/handler/handler.go6
2 files changed, 17 insertions, 1 deletions
diff --git a/sms-service/src/sms/backend/vault.go b/sms-service/src/sms/backend/vault.go
index 289fa3a..c3bbbc5 100644
--- a/sms-service/src/sms/backend/vault.go
+++ b/sms-service/src/sms/backend/vault.go
@@ -202,6 +202,18 @@ func (v *Vault) CreateSecret(dom string, sec Secret) error {
// DeleteSecretDomain deletes a secret domain which translates to
// an unmount operation on the given path in Vault
func (v *Vault) DeleteSecretDomain(name string) error {
+ err := v.checkToken()
+ if err != nil {
+ return err
+ }
+
+ name = strings.TrimSpace(name)
+ mountPath := v.vaultMount + "/" + name
+
+ err = v.vaultClient.Sys().Unmount(mountPath)
+ if err != nil {
+ return errors.New("Unable to delete domain specified")
+ }
return nil
}
diff --git a/sms-service/src/sms/handler/handler.go b/sms-service/src/sms/handler/handler.go
index f5a0a0d..48d940f 100644
--- a/sms-service/src/sms/handler/handler.go
+++ b/sms-service/src/sms/handler/handler.go
@@ -70,7 +70,11 @@ func (h handler) deleteSecretDomainHandler(w http.ResponseWriter, r *http.Reques
vars := mux.Vars(r)
domName := vars["domName"]
- h.secretBackend.DeleteSecretDomain(domName)
+ err := h.secretBackend.DeleteSecretDomain(domName)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
// createSecretHandler handles creation of secrets on a given domain name