pub struct AwsSign<'a, T>{
method: &'a str,
url: Url,
datetime: &'a DateTime<Utc>,
region: &'a str,
access_key: &'a str,
secret_key: &'a str,
headers: T,
payload_override: Option<String>,
service: &'a str,
body: &'a [u8],
}Expand description
Low-level AWS Signature Version 4 signing primitive.
Holds all inputs needed to produce the canonical request, string-to-sign,
and final Authorization header value. Construct via AwsSign::new and
then call AwsSign::sign to obtain the header value.
Fields§
§method: &'a str§url: Url§datetime: &'a DateTime<Utc>§region: &'a str§access_key: &'a str§secret_key: &'a str§headers: T§payload_override: Option<String>§service: &'a str§body: &'a [u8]body, such as in an http POST
Implementations§
Source§impl<'a> AwsSign<'a, HashMap<String, String>>
Create a new AwsSign instance
impl<'a> AwsSign<'a, HashMap<String, String>>
Create a new AwsSign instance
§Arguments
method- HTTP method (GET, POST, etc.)url- URL to signdatetime- Date and time of the requestheaders- HTTP headersregion- AWS regionaccess_key- AWS access keysecret_key- AWS secret keyservice- AWS service codebody- Request bodysigned_headers- Optional list of signed headers, used to check inbound request signature
§Returns
A new instance of AwsSign
Source§impl<'a, T> AwsSign<'a, T>
impl<'a, T> AwsSign<'a, T>
Sourcepub fn set_payload_override(&mut self, h: String)
pub fn set_payload_override(&mut self, h: String)
for streaming uploads, we need to override the payload hash
with the actual payload hash
this is used for the UNSIGNED-PAYLOAD case
and for the payload_override case
Override the payload hash used in the canonical request.
Use "UNSIGNED-PAYLOAD" for presigned URLs or streaming uploads where
the body hash is not computed up front.
Sourcepub fn canonical_header_string(&'a self) -> String
pub fn canonical_header_string(&'a self) -> String
Return the canonicalized header string for inclusion in the canonical request.
Headers are sorted lexicographically and each entry is formatted as
lowercase-name:trimmed-value\n.
Sourcepub fn signed_header_string(&'a self) -> String
pub fn signed_header_string(&'a self) -> String
Return the semicolon-separated list of signed header names (lowercase, sorted).
Sourcepub fn canonical_request(&'a self) -> String
pub fn canonical_request(&'a self) -> String
Build the canonical request string as defined in the AWS SigV4 spec.
Format: METHOD\nURI\nQUERY\nHEADERS\nSIGNED_HEADERS\nPAYLOAD_HASH