-
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
Use MD5 to sign S3 SigV4 bodies #920
Conversation
# impact, we opt to not SHA256 sign the body. Instead, we MD5 it. | ||
# We will fall back to SHA256 when MD5 is not available, such as with | ||
# FIPS systems. | ||
if MD5_AVAILABLE: |
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.
Can't we just check if there's a Content-MD5 value in the request headers? Seems more definitive.
I think we need to have a config option to enable/disable this. Especially given that users can reject requests without unsigned payloads via IAM policies (http://docs.aws.amazon.com/AmazonS3/latest/API/bucket-policy-s3-sigv4-conditions.html), we need to give them a way to enable this behavior if needed. I think I still prefer only doing this for the streaming s3 requests (put_object/upload_part) but I'm interested to hear other's thoughts. |
e052515
to
3cda647
Compare
I updated to check for the header and added a config flag. Still need to look into making this exclusive to UploadPart and PutObject |
Personally, I think we should go for unsigned payloads regardless. It keeps things simple on our side and provides the performance boost consistently. What do you think @kyleknap |
I talked to you about this, but wanted to capture the conversation. Lets only do unsigned payload for
|
I'm going to switch this to incorporating-feedback. Seems like this is going to change based on @kyleknap 's feedback so I'll defer reviewing this until those changes are made. |
2a9ea1e
to
24da5d3
Compare
Rebased on top of #936 to take advantage of context plumbing. |
0abf4a6
to
5a3a7f1
Compare
Squashed the commits. Only the top commit needs to be reviewed. |
if s3_config is None: | ||
s3_config = {} | ||
use_sha256 = s3_config.get('sha256_sign_s3v4_payload', False) | ||
if request_signer.signature_version == 's3v4' and \ |
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.
Questions for everyone: if the users opt-in to sha256_sign_s3v4_payload, should we also do MD5 calculation? Based on the docstring you have it is not clear that you turn off MD5 signing.
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.
You're right, we shouldn't disable MD5. Rather, we should enforce SHA256 if that config isn't explicitly set and MD5 isn't present.
Moved the config value checking into auth so that MD5 is not impacted. |
d2ebf1d
to
5882277
Compare
Rebased against the latest redirector and tentatively changed the name to |
s3_config = {} | ||
|
||
sign_payload = s3_config.get('payload_signing_enabled') | ||
if sign_payload in [True, 'True', 'true']: |
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.
-1 to this. We shouldn't let the lack of typed parsing in the parser/config objects leak into dependent objects. I would prefer we try to normalize this as high up the stack as we can. Likely in the client creator for now.
Updated |
Looks good to me. Thanks for incorporating the feedback. |
10cda43
to
70e16bf
Compare
Current coverage is 97.31%@@ develop #920 diff @@
==========================================
Files 43 43
Lines 6909 7014 +105
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 6721 6826 +105
Misses 188 188
Partials 0 0
|
70e16bf
to
ef0ff52
Compare
da6f25fbf541885a243ad90a3ecee3604aefa444 looks good to me. |
Knowing the headers can be useful, especially when the service model does not add them to the actual response.
S3 generally provides enough information for us to redirect requests, so this attempts to do so. To prevent a massive number of additional requests, bucket regions are cached. When a redirect occurs, a warning is printed that tells the customer they should use a client configured to the proper region to avoid additional requests.
ef0ff52
to
fac97c8
Compare
@JordonPhillips failing build? |
🚢 Thanks for all the work you put into it. |
@jamesls it's codecov. What is our official target percent? |
S3 now supports optional SHA256 body signing, so this switches from SHA256 to MD5 to boost speed while reducing CPU and Memory usage when using sigv4 with S3. SHA256 will still be used on systems which do not support using MD5.
061ad69
to
d6d7f1e
Compare
S3 now supports optional SHA256 body signing, so this switches from SHA256 to MD5 to boost speed while reducing CPU and Memory usage when using sigv4 with S3. SHA256 will still be used on systems which do not support using MD5.
cc @kyleknap @jamesls