Skip to main content

AwsSign

Struct AwsSign 

Source
pub struct AwsSign<'a, T>
where &'a T: IntoIterator<Item = (&'a String, &'a String)>, T: Debug + 'a,
{ 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

§Arguments

  • method - HTTP method (GET, POST, etc.)
  • url - URL to sign
  • datetime - Date and time of the request
  • headers - HTTP headers
  • region - AWS region
  • access_key - AWS access key
  • secret_key - AWS secret key
  • service - AWS service code
  • body - Request body
  • signed_headers - Optional list of signed headers, used to check inbound request signature

§Returns

A new instance of AwsSign

Source

pub fn new<B: AsRef<[u8]> + ?Sized>( method: &'a str, url: &'a str, datetime: &'a DateTime<Utc>, headers: &'a HeaderMap, region: &'a str, access_key: &'a str, secret_key: &'a str, service: &'a str, body: &'a B, _signed_headers: Option<&'a Vec<String>>, ) -> Self

Source§

impl<'a, T> AwsSign<'a, T>
where &'a T: IntoIterator<Item = (&'a String, &'a String)>, T: Debug,

Source

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.

Source

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.

Source

pub fn signed_header_string(&'a self) -> String

Return the semicolon-separated list of signed header names (lowercase, sorted).

Source

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

Source

pub fn sign(&'a self) -> String

Compute and return the complete Authorization header value.

The returned string can be set directly on the outgoing request with request.insert_header("authorization", sign_result).

Trait Implementations§

Source§

impl<'a, T> Debug for AwsSign<'a, T>
where &'a T: IntoIterator<Item = (&'a String, &'a String)>, T: Debug,

custom debug implementation to redact secret_key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for AwsSign<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for AwsSign<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for AwsSign<'a, T>
where T: Send,

§

impl<'a, T> Sync for AwsSign<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for AwsSign<'a, T>
where T: Unpin,

§

impl<'a, T> UnsafeUnpin for AwsSign<'a, T>
where T: UnsafeUnpin,

§

impl<'a, T> UnwindSafe for AwsSign<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Ungil for T
where T: Send,