Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Unsealer: Merge commit was botched; fix WrappedTokenUnsealer
Browse files Browse the repository at this point in the history
  • Loading branch information
nemosupremo committed Sep 2, 2016
1 parent 928e2c8 commit 50e35d9
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions unsealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,26 +303,29 @@ func (t WrappedTokenUnsealer) Token() (string, error) {
return "", e
}

vaultWrappedResp := struct {
Data struct {
WrappedSecret struct {
Token string `json:"token"`
} `json:"response"`
} `json:"data"`
}{}
var vaultWrappedResp VaultWrappedResponse

if err := resp.Body.FromJsonTo(&vaultWrappedResp); err != nil {
return "", err
}

secretResp := struct {
Auth struct {
ClientToken string `json:"client_token"`
} `json:"auth"`
}{}

if err := vaultWrappedResp.Unwrap(&secretResp); err != nil {
return "", err
}

if vaultWrappedResp.Data.WrappedSecret.Token == "" {
if secretResp.Auth.ClientToken == "" {
return "", errInvalidWrappedToken
}

return TokenUnsealer{vaultWrappedResp.Data.WrappedSecret.Token}.Token()
return TokenUnsealer{secretResp.Auth.ClientToken}.Token()
}

func (t WrappedTokenUnsealer) Name() string {
return "wrapped-token"
}
}

0 comments on commit 50e35d9

Please sign in to comment.