Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add x-amz-content-sha256 to CanonicalHeaders #179

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

hanbing0715
Copy link
Contributor

As writing in Signature Calculations for the Authorization Header: Transferring Payload in a Single Chunk (AWS Signature Version 4)

The x-amz-content-sha256 header is required for all AWS Signature Version 4 requests. It provides a hash of the request payload. If there is no payload, you must provide the hash of an empty string.

For the purpose of calculating an authorization signature, only the host and any x-amz-* headers are required;

We should add x-amz-content-sha256 to CanonicalHeaders

@4141done
Copy link
Collaborator

Hi @hanbing0715, thank you very much for your contribution. This looks simple but I am going to take some time in the next few days to make sure I fully understand since this is new to me.

@4141done
Copy link
Collaborator

Hi @hanbing0715, thank you for your patience. I have been able to test this change and understand the documentation so this looks good! The tests are currently failing because the expected signing key hash does not include this header.

Can you please update your branch with the following change?

diff --git a/test/unit/awssig4_test.js b/test/unit/awssig4_test.js
index 351aed4..b1f3612 100644
--- a/test/unit/awssig4_test.js
+++ b/test/unit/awssig4_test.js
@@ -74,7 +74,7 @@ function _runSignatureV4(r) {
     const canonicalRequest = awssig4._buildCanonicalRequest(r,
         r.method, req.uri, req.queryParams, req.host, amzDatetime, creds.sessionToken);

-    var expected = '600721cacc21e3de14416de7517868381831f4709e5c5663bbf2b738e4d5abe4';
+    var expected = 'cf4dd9e1d28c74e2284f938011efc8230d0c20704f56f67e4a3bfc2212026bec';
     var signature = awssig4._buildSignatureV4(r,
         amzDatetime, eightDigitDate, creds, region, service, canonicalRequest);

Alternately, you could give me permission to push to your branch I can add the small change.

@hanbing0715
Copy link
Contributor Author

Hello @4141done , I have change the expected result of awssig4, plz rerun the test.

@4141done 4141done merged commit 085ae0f into nginxinc:master Oct 16, 2023
2 checks passed
@4141done
Copy link
Collaborator

Thank you again for your contribution @hanbing0715 !

@hanbing0715 hanbing0715 deleted the patch-1 branch October 17, 2023 06:11
elJosho pushed a commit to elJosho/nginx-s3-gateway that referenced this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants