Skip to content

Commit 79ead48

Browse files
Make SigningInstructions public (#2730)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> I'm building an s3 server in rust and I need signature verification to work from the server side when receiving requests. To do that the server needs to generate a signature and then compare it to the one that the client has already sent along. I believe that the sign module in aws-sigv4 http_request contains the functions required to do that. <!--- If it fixes an open issue, please link to the issue here --> ## Description <!--- Describe your changes in detail --> Exported the `SigningInstructions` struct in the sign module of http_request for aws-sigv4. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Chris Holcombe <chholcombe@tesla.com> Co-authored-by: John DiSanti <jdisanti@amazon.com>
1 parent 9fe5d55 commit 79ead48

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.next.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,9 @@ message = "For event stream operations, the `EventStreamSender` in inputs/output
6262
references = ["smithy-rs#2673"]
6363
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all"}
6464
author = "jdisanti"
65+
66+
[[aws-sdk-rust]]
67+
message = "The `SigningInstructions` in the `aws-sigv4` module are now public. This allows them to be named in a function signature."
68+
references = ["smithy-rs#2730"]
69+
author = "cholcombe973"
70+
meta = { "breaking" = false, "tada" = false, "bug" = true }

aws/rust-runtime/aws-sigv4/src/http_request/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ pub use settings::{
5656
PayloadChecksumKind, PercentEncodingMode, SessionTokenMode, SignatureLocation, SigningParams,
5757
SigningSettings, UriPathNormalizationMode,
5858
};
59-
pub use sign::{sign, SignableBody, SignableRequest};
59+
pub use sign::{sign, SignableBody, SignableRequest, SigningInstructions};

aws/rust-runtime/aws-sigv4/src/http_request/sign.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub enum SignableBody<'a> {
103103
StreamingUnsignedPayloadTrailer,
104104
}
105105

106+
/// Instructions for applying a signature to an HTTP request.
106107
#[derive(Debug)]
107108
pub struct SigningInstructions {
108109
headers: Option<HeaderMap<HeaderValue>>,
@@ -117,20 +118,27 @@ impl SigningInstructions {
117118
Self { headers, params }
118119
}
119120

121+
/// Returns a reference to the headers that should be added to the request.
120122
pub fn headers(&self) -> Option<&HeaderMap<HeaderValue>> {
121123
self.headers.as_ref()
122124
}
125+
126+
/// Returns the headers and sets the internal value to `None`.
123127
pub fn take_headers(&mut self) -> Option<HeaderMap<HeaderValue>> {
124128
self.headers.take()
125129
}
126130

131+
/// Returns a reference to the query parameters that should be added to the request.
127132
pub fn params(&self) -> Option<&Vec<(&'static str, Cow<'static, str>)>> {
128133
self.params.as_ref()
129134
}
135+
136+
/// Returns the query parameters and sets the internal value to `None`.
130137
pub fn take_params(&mut self) -> Option<Vec<(&'static str, Cow<'static, str>)>> {
131138
self.params.take()
132139
}
133140

141+
/// Applies the instructions to the given `request`.
134142
pub fn apply_to_request<B>(mut self, request: &mut http::Request<B>) {
135143
if let Some(new_headers) = self.take_headers() {
136144
for (name, value) in new_headers.into_iter() {

0 commit comments

Comments
 (0)