From 3120376762853b3098fda7e9217fb39fe1bf5105 Mon Sep 17 00:00:00 2001 From: Ran Vaknin <50976344+RanVaknin@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:56:33 -0700 Subject: [PATCH] =?UTF-8?q?refactoring=20of=20buildQuery=20to=20accept=20a?= =?UTF-8?q?=20list=20of=20maintained=20headers=20to=20l=E2=80=A6=20(#2773)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/2ab6aa4259a34a4d966c84b440837c93.json | 8 ++++++++ aws/signer/v4/v4.go | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .changelog/2ab6aa4259a34a4d966c84b440837c93.json diff --git a/.changelog/2ab6aa4259a34a4d966c84b440837c93.json b/.changelog/2ab6aa4259a34a4d966c84b440837c93.json new file mode 100644 index 00000000000..727e2a56d05 --- /dev/null +++ b/.changelog/2ab6aa4259a34a4d966c84b440837c93.json @@ -0,0 +1,8 @@ +{ + "id": "2ab6aa42-59a3-4a4d-966c-84b440837c93", + "type": "bugfix", + "description": "refactoring of buildQuery to accept a map of hand maintained headers to lowercase because of an S3 limitation", + "modules": [ + "." + ] +} \ No newline at end of file diff --git a/aws/signer/v4/v4.go b/aws/signer/v4/v4.go index dcd896a9bf6..7ed91d5bac1 100644 --- a/aws/signer/v4/v4.go +++ b/aws/signer/v4/v4.go @@ -394,11 +394,16 @@ func (s *httpSigner) buildCredentialScope() string { func buildQuery(r v4Internal.Rule, header http.Header) (url.Values, http.Header) { query := url.Values{} unsignedHeaders := http.Header{} + + // A list of headers to be converted to lower case to mitigate a limitation from S3 + lowerCaseHeaders := map[string]string{ + "X-Amz-Expected-Bucket-Owner": "x-amz-expected-bucket-owner", // see #2508 + "X-Amz-Request-Payer": "x-amz-request-payer", // see #2764 + } + for k, h := range header { - // literally just this header has this constraint for some stupid reason, - // see #2508 - if k == "X-Amz-Expected-Bucket-Owner" { - k = "x-amz-expected-bucket-owner" + if newKey, ok := lowerCaseHeaders[k]; ok { + k = newKey } if r.IsValid(k) {