-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
only add the content-sha256 header when it's already exists for CrtSigV4QueryAuth and CrtSigV4AsymQueryAuth #3243
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #3243 +/- ##
===========================================
- Coverage 93.15% 93.12% -0.04%
===========================================
Files 66 66
Lines 14287 14291 +4
===========================================
- Hits 13309 13308 -1
- Misses 978 983 +5 ☔ View full report in Codecov by Sentry. |
@@ -81,7 +81,7 @@ def add_auth(self, request): | |||
else: | |||
explicit_payload = UNSIGNED_PAYLOAD | |||
|
|||
if self._should_add_content_sha256_header(explicit_payload): | |||
if self._should_add_content_sha256_header(existing_sha256, explicit_payload): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always add new positional arguments at the end of the function signature. I would also recommend making this an optional parameter that defaults to None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we also missed an update somewhere? I think this will be resolved if you follow the advice above, but we should figure out where we're missing.
TypeError: _should_add_content_sha256_header() takes 2 positional arguments but 3 were given
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the error, but I don't understand why... Looks like we are not declaring _should_add_content_sha256_header
anywhere else, and I updated the param for _should_add_content_sha256_header
in CrtSigV4QueryAuth
. Interesting.
# only add X-Amz-Content-SHA256 header if header already set to UNSIGNED_PAYLOAD | ||
return existing_sha256 == UNSIGNED_PAYLOAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we only adding this if it's unsigned? What if we have an actual payload we're signing for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a temporary workaround we want to add for vpc-lattice and not want to introduce the change for others (Even though that it might be more reasonable to add the header to sign for other service as well, and it will match the behavior for the botocore signer). And they only supports UNSIGNED-PAYLOAD
We decided to have an other workaround as the short term patch within CRT now. awslabs/aws-c-auth#249
We will have further discussion about what's the proper way to handle their use case in the near future, and it should be across SDKs not only for CRT.
So, no need for this PR now.
I'll close this PR as we don't need this change now. We already kicked off the release for the alternative change in CRT, as long as we pick up the latest version v0.21.4 once it's release, we should be good |
_should_add_content_sha256_header
forCrtSigV4QueryAuth
andCrtSigV4AsymQueryAuth
to add thecontent_sha256
header if the request to sign already have the header, instead of relying on the mix of the configurations and the headers in request to sign.x-amz-content-sha256
header when_should_sha256_sign_payload
is disabled.Extra notes:
CrtSigV4QueryAuth
andCrtSigV4AsymQueryAuth
will never add thex-amz-content-sha256
header, with the change from CRT, we consider to addx-amz-content-sha256
header to the signed request if your original request to sign has the header set to "UNSIGNED-PAYLOAD". From add content-sha256 header for presign when the signed_body_value is set to UNSIGNED-PAYLOAD awslabs/aws-c-auth#248request.context["payload_signing_enabled"] = False
will not add the extra header to the signed request.Will update the CRT version and add tests.