From 50e35d915e248e43a118506817a05a40f7ab15d6 Mon Sep 17 00:00:00 2001 From: Nimi Wariboko Jr Date: Thu, 1 Sep 2016 20:43:56 -0700 Subject: [PATCH] Unsealer: Merge commit was botched; fix WrappedTokenUnsealer --- unsealer.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/unsealer.go b/unsealer.go index 2ddc8bc..2bbe7f7 100644 --- a/unsealer.go +++ b/unsealer.go @@ -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" -} \ No newline at end of file +}