From 76a474cbb192e48fefaa368cbafba63e4d3d308e Mon Sep 17 00:00:00 2001 From: Annalise Diroff Date: Wed, 3 Nov 2021 08:37:43 -0700 Subject: [PATCH 1/3] initial fix for unwrap bug --- api/logical.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/logical.go b/api/logical.go index f8f8bc537661..8a6c1c2fb19d 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.TrimSuffix(string(wrappingToken), "\n") 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, } } } From 02b6129896b8d8b669bb4bcab8143077a98fd4df Mon Sep 17 00:00:00 2001 From: Annalise Diroff Date: Thu, 4 Nov 2021 09:08:28 -0700 Subject: [PATCH 2/3] Adding change log --- changelog/13044.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/13044.txt diff --git a/changelog/13044.txt b/changelog/13044.txt new file mode 100644 index 000000000000..1da07ac0b0b9 --- /dev/null +++ b/changelog/13044.txt @@ -0,0 +1,3 @@ +```release-note:improvement +trims newline character from wrapping token in UnWrap Go SDK +``` \ No newline at end of file From b8f9ad98798e4b74f7e216a48b4c8bc0571a73f3 Mon Sep 17 00:00:00 2001 From: Annalise Diroff Date: Tue, 16 Nov 2021 11:26:51 -0800 Subject: [PATCH 3/3] Trim all whitespace --- api/logical.go | 2 +- changelog/13044.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/logical.go b/api/logical.go index 8a6c1c2fb19d..68f3e9100506 100644 --- a/api/logical.go +++ b/api/logical.go @@ -236,7 +236,7 @@ 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.TrimSuffix(string(wrappingToken), "\n") + wt := strings.TrimSpace(wrappingToken) if wrappingToken != "" { if c.c.Token() == "" { c.c.SetToken(wt) diff --git a/changelog/13044.txt b/changelog/13044.txt index 1da07ac0b0b9..3896544c4746 100644 --- a/changelog/13044.txt +++ b/changelog/13044.txt @@ -1,3 +1,3 @@ ```release-note:improvement -trims newline character from wrapping token in UnWrap Go SDK +api: Trim newline character from wrapping token in logical.Unwrap from the api package ``` \ No newline at end of file