Skip to content

Commit

Permalink
Send initialized information via sys/seal-status (#5424)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai authored and briankassouf committed Sep 27, 2018
1 parent e559a1f commit 382f28e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/sys_seal.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func sealStatusRequest(c *Sys, r *Request) (*SealStatusResponse, error) {

type SealStatusResponse struct {
Type string `json:"type"`
Initialized bool `json:"initialized"`
Sealed bool `json:"sealed"`
T int `json:"t"`
N int `json:"n"`
Expand Down
1 change: 1 addition & 0 deletions command/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ func OutputSealStatus(ui cli.Ui, client *api.Client, status *api.SealStatusRespo
out := []string{}
out = append(out, "Key | Value")
out = append(out, fmt.Sprintf("%sSeal Type | %s", sealPrefix, status.Type))
out = append(out, fmt.Sprintf("Initialized | %t", status.Initialized))
out = append(out, fmt.Sprintf("Sealed | %t", status.Sealed))
out = append(out, fmt.Sprintf("Total %sShares | %d", sealPrefix, status.N))
out = append(out, fmt.Sprintf("Threshold | %d", status.T))
Expand Down
9 changes: 8 additions & 1 deletion http/sys_seal.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req
}

if sealConfig == nil {
respondError(w, http.StatusBadRequest, fmt.Errorf("server is not yet initialized"))
respondOk(w, &SealStatusResponse{
Type: core.SealAccess().BarrierType(),
Initialized: false,
Sealed: true,
RecoverySeal: core.SealAccess().RecoveryKeySupported(),
})
return
}

Expand All @@ -201,6 +206,7 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req

respondOk(w, &SealStatusResponse{
Type: sealConfig.Type,
Initialized: true,
Sealed: sealed,
T: sealConfig.SecretThreshold,
N: sealConfig.SecretShares,
Expand All @@ -215,6 +221,7 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req

type SealStatusResponse struct {
Type string `json:"type"`
Initialized bool `json:"initialized"`
Sealed bool `json:"sealed"`
T int `json:"t"`
N int `json:"n"`
Expand Down
4 changes: 4 additions & 0 deletions vault/seal_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func (s *SealAccess) StoredKeysSupported() bool {
return s.seal.StoredKeysSupported()
}

func (s *SealAccess) BarrierType() string {
return s.seal.BarrierType()
}

func (s *SealAccess) BarrierConfig(ctx context.Context) (*SealConfig, error) {
return s.seal.BarrierConfig(ctx)
}
Expand Down

0 comments on commit 382f28e

Please sign in to comment.