mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-31 18:48:08 +00:00
http: /sys/seal requires a token
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/hashicorp/errwrap"
|
"github.com/hashicorp/errwrap"
|
||||||
|
"github.com/hashicorp/vault/logical"
|
||||||
"github.com/hashicorp/vault/vault"
|
"github.com/hashicorp/vault/vault"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,7 +18,11 @@ func handleSysSeal(core *vault.Core) http.Handler {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := core.Seal(); err != nil {
|
// Get the auth for the request so we can access the token directly
|
||||||
|
req := requestAuth(r, &logical.Request{})
|
||||||
|
|
||||||
|
// Seal with the token above
|
||||||
|
if err := core.Seal(req.ClientToken); err != nil {
|
||||||
respondError(w, http.StatusInternalServerError, err)
|
respondError(w, http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,14 +65,10 @@ func TestSysSeal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSysSeal_unsealed(t *testing.T) {
|
func TestSysSeal_unsealed(t *testing.T) {
|
||||||
core := vault.TestCore(t)
|
core, _, token := vault.TestCoreUnsealed(t)
|
||||||
ln, addr := TestServer(t, core)
|
ln, addr := TestServer(t, core)
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
|
TestServerAuth(t, addr, token)
|
||||||
key, _ := vault.TestCoreInit(t, core)
|
|
||||||
if _, err := core.Unseal(key); err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := testHttpPut(t, addr+"/v1/sys/seal", nil)
|
resp := testHttpPut(t, addr+"/v1/sys/seal", nil)
|
||||||
testResponseStatus(t, resp, 204)
|
testResponseStatus(t, resp, 204)
|
||||||
|
|||||||
Reference in New Issue
Block a user