Skip to content

Commit

Permalink
Backport 9825 1.5.x (#9835)
Browse files Browse the repository at this point in the history
* Add X-Amz-Credential

* Reorder imports

* go fmt
  • Loading branch information
sgmiller committed Aug 26, 2020
1 parent 268738a commit fc5336e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions builtin/credential/aws/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
)

const amzHeaderPrefix = "X-Amz-"

var defaultAllowedSTSRequestHeaders = []string{
"X-Amz-Date",
"X-Amz-Credential",
"X-Amz-Security-Token",
"X-Amz-Algorithm",
"X-Amz-Signature",
Expand Down
4 changes: 2 additions & 2 deletions builtin/credential/aws/path_config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package awsauth
import (
"context"
"errors"
"github.com/hashicorp/vault/sdk/helper/strutil"
"net/http"
"net/textproto"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/helper/strutil"
"github.com/hashicorp/vault/sdk/logical"
)

Expand Down Expand Up @@ -336,7 +336,7 @@ type clientConfig struct {
func (c *clientConfig) validateAllowedSTSHeaderValues(headers http.Header) error {
for k := range headers {
h := textproto.CanonicalMIMEHeaderKey(k)
if strings.HasPrefix(h, amzHeaderPrefix) &&
if strings.HasPrefix(h, amzHeaderPrefix) &&
!strutil.StrListContains(defaultAllowedSTSRequestHeaders, h) &&
!strutil.StrListContains(c.AllowedSTSHeaderValues, h) {
return errors.New("invalid request header: " + k)
Expand Down

0 comments on commit fc5336e

Please sign in to comment.