Unverified Commit 2d615022 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Remove the public HTTP dependency from aws-sigv4 (#2921)

## Motivation and Context
Removes the public http dependency from the aws-sigv4 crate to avoid
compatibility issues with http = 1.0 and to support the http refactor

## Description
- Changes `SignableRequest::new` to remove the direct exposure of HTTP
types
- Assorted test refactorings as a result
- Update calling code

## Testing
IT/UT

## Checklist
TODO: changelog
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 89802592
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -34,3 +34,14 @@ message = "Fix requests to S3 with `no_credentials` set."
references = ["smithy-rs#2907", "aws-sdk-rust#864"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "jdisanti"

[[aws-sdk-rust]]
message = """Several breaking changes were made to the aws-sigv4 API to remove the direct HTTP dependency:
- The `take_parameters` and `take_headers` APIs were removed from `SigningInstructions`. Use `into_parts()` instead
- The arguments of `SignableRequest::new` were changed to accept string types instead of types from the HTTP crate
- `SigningInstructions::apply_to_request` was gated beyond an `http0-compat` feature flag for backwards compatibility. This API MAY be removed in a future release.
- Several public accessors were removed from `SigningInstructions`.
"""
references = ["smithy-rs#2921"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "rcoh"
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ test-util = []
[dependencies]
aws-credential-types = { path = "../aws-credential-types" }
aws-http = { path = "../aws-http" }
aws-sigv4 = { path = "../aws-sigv4" }
# TODO(httpRefactor): Remove the http0-compat feature
aws-sigv4 = { path = "../aws-sigv4", features = ["http0-compat"] }
aws-smithy-async = { path = "../../../rust-runtime/aws-smithy-async" }
aws-smithy-eventstream = { path = "../../../rust-runtime/aws-smithy-eventstream", optional = true }
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
+10 −5
Original line number Diff line number Diff line
@@ -356,11 +356,17 @@ impl Signer for SigV4Signer {
                });

            let signable_request = SignableRequest::new(
                request.method(),
                request.uri(),
                request.headers(),
                request.method().as_str(),
                request.uri().to_string(),
                request.headers().iter().map(|(k, v)| {
                    (
                        k.as_str(),
                        // use from_utf8 instead of to_str because we _do_ allow non-ascii header values
                        std::str::from_utf8(v.as_bytes()).expect("only utf-8 headers are signable"),
                    )
                }),
                signable_body,
            );
            )?;
            sign(signable_request, &signing_params)?
        }
        .into_parts();
@@ -384,7 +390,6 @@ impl Signer for SigV4Signer {
                    .expect("failed to send deferred signer");
            }
        }

        signing_instructions.apply_to_request(request);
        Ok(())
    }
+2 −1
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ sign-eventstream = ["aws-smithy-eventstream", "aws-sigv4/sign-eventstream"]

[dependencies]
aws-credential-types = { path = "../aws-credential-types" }
aws-sigv4 = { path = "../aws-sigv4" }
# TODO(httpRefactor): Remove feature was http refactor is complete
aws-sigv4 = { path = "../aws-sigv4", features = ["http0-compat"] }
aws-smithy-eventstream = { path = "../../../rust-runtime/aws-smithy-eventstream", optional = true }
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
aws-smithy-async = { path = "../../../rust-runtime/aws-smithy-async" }
+11 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use std::time::{Duration, SystemTime};

use crate::middleware::Signature;
pub use aws_sigv4::http_request::SignableBody;

pub type SigningError = aws_sigv4::http_request::SigningError;

const EXPIRATION_WARNING: &str = "Presigned request will expire before the given \
@@ -212,11 +213,17 @@ impl SigV4Signer {
                });

            let signable_request = SignableRequest::new(
                request.method(),
                request.uri(),
                request.headers(),
                request.method().as_str(),
                request.uri().to_string(),
                request.headers().iter().map(|(k, v)| {
                    (
                        k.as_str(),
                        std::str::from_utf8(v.as_bytes())
                            .expect("only string headers are signable"),
                    )
                }),
                signable_body,
            );
            )?;
            sign(signable_request, &signing_params)?
        }
        .into_parts();
Loading