Skip to content

Commit

Permalink
Sync ignored v4 presign headers (#1639)
Browse files Browse the repository at this point in the history
fixes #1629
  • Loading branch information
superseb authored Apr 16, 2022
1 parent deb9ab4 commit 8142170
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
23 changes: 12 additions & 11 deletions pkg/signer/request-signature-v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,22 @@ const (
// Excerpts from @lsegal -
// https:/github.com/aws/aws-sdk-js/issues/659#issuecomment-120477258.
//
// User-Agent:
// * User-Agent
// This is ignored from signing because signing this causes problems with generating pre-signed
// URLs (that are executed by other agents) or when customers pass requests through proxies, which
// may modify the user-agent.
//
// This is ignored from signing because signing this causes
// problems with generating pre-signed URLs (that are executed
// by other agents) or when customers pass requests through
// proxies, which may modify the user-agent.
// * Authorization
// Is skipped for obvious reasons.
//
//
// Authorization:
//
// Is skipped for obvious reasons
// * Accept-Encoding
// Some S3 servers like Hitachi Content Platform do not honor this header for signature
// calculation.
//
var v4IgnoredHeaders = map[string]bool{
"Authorization": true,
"User-Agent": true,
"Accept-Encoding": true,
"Authorization": true,
"User-Agent": true,
}

// getSigningKey hmac seed to calculate final signature.
Expand Down
3 changes: 2 additions & 1 deletion pkg/signer/request-signature-v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ func buildRequest(serviceName, region, body string) (*http.Request, io.ReadSeeke
reader := strings.NewReader(body)
req, _ := http.NewRequest(http.MethodPost, endpoint, reader)
req.URL.Opaque = "//example.org/bucket/key-._~,!@#$%^&*()"
req.Header.Add("X-Amz-Target", "prefix.Operation")
req.Header.Add("Accept-Encoding", "identity")
req.Header.Add("Content-Type", "application/x-amz-json-1.0")
req.Header.Add("Content-Length", fmt.Sprint(len(body)))
req.Header.Add("X-Amz-Meta-Other-Header", "some-value=!@#$%^&* (+)")
req.Header.Add("X-Amz-Meta-Other-Header_With_Underscore", "some-value=!@#$%^&* (+)")
req.Header.Add("X-amz-Meta-Other-Header_With_Underscore", "some-value=!@#$%^&* (+)")
req.Header.Add("X-Amz-Target", "prefix.Operation")
return req, reader
}

0 comments on commit 8142170

Please sign in to comment.