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 support for unsigned payloads in aws #3741

Merged
merged 12 commits into from
Feb 27, 2023

Conversation

trueleo
Copy link
Contributor

@trueleo trueleo commented Feb 21, 2023

Which issue does this PR close?

Closes #3737 .

Rationale for this change

Explained in #3737

What changes are included in this PR?

  • Adds with_unsigned_payload configuration option to AmazonS3Builder.
  • Adds sign_payload bool to S3Config and RequestSigner.
  • If sign_payload is set to true it will work as before and set a SHA256 hash to x-amz-content-sha256. Otherwise it will set it as "UNSIGNED_PAYLOAD"

Are there any user-facing changes?

  • AmazonS3Builder has a new method named with_unsigned_payload

@github-actions github-actions bot added the object-store Object Store Interface label Feb 21, 2023
Copy link
Contributor

@roeap roeap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add the appropriate key to AmazonS3ConfigKey, and corresponding parsing (FromStr) and serialisation (AsRef) methods, such that the new option can be configured via the storage options interface.

@trueleo
Copy link
Contributor Author

trueleo commented Feb 22, 2023

@roeap How do we add integration test for this option.

@roeap
Copy link
Contributor

roeap commented Feb 22, 2023

How do we add integration test for this option.

There are some tests for these options, you could add a case in that test.

fn s3_test_config_from_typed_map() {
let aws_access_key_id = "object_store:fake_access_key_id".to_string();
let aws_secret_access_key = "object_store:fake_secret_key".to_string();
let aws_default_region = "object_store:fake_default_region".to_string();
let aws_endpoint = "object_store:fake_endpoint".to_string();
let aws_session_token = "object_store:fake_session_token".to_string();
let options = HashMap::from([
(AmazonS3ConfigKey::AccessKeyId, aws_access_key_id.clone()),
(AmazonS3ConfigKey::SecretAccessKey, aws_secret_access_key),
(AmazonS3ConfigKey::DefaultRegion, aws_default_region.clone()),
(AmazonS3ConfigKey::Endpoint, aws_endpoint.clone()),
(AmazonS3ConfigKey::Token, aws_session_token.clone()),
]);
let builder = AmazonS3Builder::new()
.try_with_options(&options)
.unwrap()
.try_with_option(AmazonS3ConfigKey::SecretAccessKey, "new-secret-key")
.unwrap();
assert_eq!(builder.access_key_id.unwrap(), aws_access_key_id.as_str());
assert_eq!(builder.secret_access_key.unwrap(), "new-secret-key");
assert_eq!(builder.region.unwrap(), aws_default_region);
assert_eq!(builder.endpoint.unwrap(), aws_endpoint);
assert_eq!(builder.token.unwrap(), aws_session_token);
}

@trueleo trueleo requested a review from roeap February 22, 2023 14:56
Copy link
Contributor

@roeap roeap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a few minor comments, but overall I think this looks good!

object_store/src/aws/credential.rs Show resolved Hide resolved
@@ -822,6 +837,13 @@ impl AmazonS3Builder {
self
}

/// Sets the client to not include payload checksum in signature calculation.
/// See [unsigned payload option](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)
pub fn with_unsigned_payload(mut self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in other cases for boolean options, we pass in the actual parameter, so that true and false can explicitly be set. While not overly critical, I think its better to be consistent,.

Copy link
Contributor Author

@trueleo trueleo Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this change but for reference an existing option with_imdsv1_fallback does not take boolean argument.

I am not sure what general convention are around this.

object_store/src/aws/mod.rs Show resolved Hide resolved
Copy link
Contributor

@roeap roeap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thank you. Apologies for the slow review

@@ -1222,6 +1252,14 @@ mod tests {
stream_get(&integration).await;
}

#[tokio::test]
async fn s3_test_unsigned_payload() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to race with s3_test above, it likely needs to be rolled into the same test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, will it be better to add something like https://crates.io/crates/serial_test

Copy link
Contributor

@tustvold tustvold Feb 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather avoid additional test dependencies if possible. I see no issue with just merging this into the same test as above, the stack trace will make it clear what test failed

@tustvold
Copy link
Contributor

I'm afraid I messed up the sequencing and so this missed the release today... Too many plates... Thank you once again

@ursabot
Copy link

ursabot commented Feb 27, 2023

Benchmark runs are scheduled for baseline = 5cc0f9b and contender = e7eb304. e7eb304 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@trueleo trueleo deleted the unsigned_s3_request branch February 28, 2023 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
object-store Object Store Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Unsigned S3 Payloads
4 participants