Skip to content

feat(rest): support AWS SIGv4 #1241

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Apr 24, 2025

Signed-off-by: xxchan [email protected]

Which issue does this PR close?

close #1236

There's one missing piece: reqsign got canonical request like:

  • /iceberg/v1/arn%3Aaws%3As3tables%3Aap-southeast-1...
  • but should be /iceberg/v1/arn%253Aaws%253As3tables%253Aap-southeast-1%..., where reqsign wrongly decoded %3.

During my local testing, I tried to remove this percent_decode_str in
reqsign https://github.com/Xuanwo/reqsign/blob/26a1e224b5498a59ad53d9508be1e85df322f043/src/aws/v4.rs#L223 , then it runs successfully (I tested with the iceberg-rust CLI from #1220). But I'm not sure about the decode reason here and what's the best way to change it. cc @Xuanwo

What changes are included in this PR?

Are these changes tested?

xxchan added 2 commits April 24, 2025 10:41
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
@xxchan xxchan force-pushed the xxchan/cheerful-mite branch from 8a99af2 to e698d79 Compare April 24, 2025 02:51
Comment on lines +232 to +237
const EMPTY_STRING_SHA256: &str =
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
request.headers_mut().insert(
"x-amz-content-sha256",
HeaderValue::from_str(EMPTY_STRING_SHA256).unwrap(),
);

Choose a reason for hiding this comment

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

Why do we have to hardcode this here?

@@ -220,6 +225,39 @@ impl HttpClient {
/// Executes the given `Request` and returns a `Response`.
pub async fn execute(&self, mut request: Request) -> Result<Response> {
request.headers_mut().extend(self.extra_headers.clone());

if let Some((loader, signer)) = &self.signer {
match loader.load().await {

Choose a reason for hiding this comment

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

Do we want to load credentials with every request?

            let config = AwsConfig::default().from_profile().from_env();
            println!("access_key_id {:?}", config.access_key_id);
            let loader = AwsDefaultLoader::new(self.client().unwrap_or_default(), config);

@@ -93,6 +93,7 @@ port_scanner = "0.1.5"
pretty_assertions = "1.4"
rand = "0.8.5"
regex = "1.10.5"
reqsign = { version = "0.16.3" }

Choose a reason for hiding this comment

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

Is there a reason for not using https://crates.io/crates/aws-sigv4 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

reqsign is lightweight, with minimal dependency footprints. And it's already depended by us (transitively via opendal ). So it's good not to introduce new heavy dependencies.

@Xuanwo could you share your opinions on this?

Comment on lines +335 to +338
if warehouse_path.starts_with("arn:aws:") {
let file_io = FileIOBuilder::new("s3").with_props(&props).build()?;
return Ok(file_io);
}

Choose a reason for hiding this comment

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

Is there a better way to know the rest catalog service e.g. using rest.signing-name?

Comment on lines 103 to 105
let config = AwsConfig::default().from_profile().from_env();
println!("access_key_id {:?}", config.access_key_id);
let loader = AwsDefaultLoader::new(self.client().unwrap_or_default(), config);

Choose a reason for hiding this comment

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

Can we support customizing this like passing or reusing the aws profile / credentials configuration or better introduce a new set of rest specific configurations.

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.

REST catalog: support AWS sigV4
2 participants