From eeb41dc76eb5a75abf49a624077a4a51c1ec66e4 Mon Sep 17 00:00:00 2001 From: AnPucel Date: Wed, 24 Nov 2021 10:13:45 -0800 Subject: [PATCH] Allowing Unwrap w/ Newline files (#13044) --- api/logical.go | 6 ++++-- changelog/13044.txt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/13044.txt diff --git a/api/logical.go b/api/logical.go index f8f8bc537..68f3e9100 100644 --- a/api/logical.go +++ b/api/logical.go @@ -8,6 +8,7 @@ import ( "net/http" "net/url" "os" + "strings" "github.com/hashicorp/errwrap" "github.com/hashicorp/vault/sdk/helper/jsonutil" @@ -235,12 +236,13 @@ func (c *Logical) DeleteWithData(path string, data map[string][]string) (*Secret func (c *Logical) Unwrap(wrappingToken string) (*Secret, error) { var data map[string]interface{} + wt := strings.TrimSpace(wrappingToken) if wrappingToken != "" { if c.c.Token() == "" { - c.c.SetToken(wrappingToken) + c.c.SetToken(wt) } else if wrappingToken != c.c.Token() { data = map[string]interface{}{ - "token": wrappingToken, + "token": wt, } } } diff --git a/changelog/13044.txt b/changelog/13044.txt new file mode 100644 index 000000000..3896544c4 --- /dev/null +++ b/changelog/13044.txt @@ -0,0 +1,3 @@ +```release-note:improvement +api: Trim newline character from wrapping token in logical.Unwrap from the api package +``` \ No newline at end of file