1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
//! Utilities to sign HTTP requests.
//!
//! # Example: Signing an HTTP request
//!
//! ```rust
//! # fn test() -> Result<(), aws_sigv4::http_request::SigningError> {
//! use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest};
//! use http;
//! use std::time::SystemTime;
//!
//! // Create the request to sign
//! let mut request = http::Request::builder()
//! .uri("https://some-endpoint.some-region.amazonaws.com")
//! .body("")
//! .unwrap();
//!
//! // Set up information and settings for the signing
//! let signing_settings = SigningSettings::default();
//! let signing_params = SigningParams::builder()
//! .access_key("example access key")
//! .secret_key("example secret key")
//! .region("us-east-1")
//! .service_name("exampleservice")
//! .time(SystemTime::now())
//! .settings(signing_settings)
//! .build()
//! .unwrap();
//! // Convert the HTTP request into a signable request
//! let signable_request = SignableRequest::from(&request);
//!
//! // Sign and then apply the signature to the request
//! let (signing_instructions, _signature) = sign(signable_request, &signing_params)?.into_parts();
//! signing_instructions.apply_to_request(&mut request);
//! # Ok(())
//! # }
//! ```
//!
mod canonical_request;
mod error;
mod query_writer;
mod settings;
mod sign;
mod uri_path_normalization;
mod url_escape;
#[cfg(test)]
pub(crate) mod test;
pub use error::SigningError;
pub use settings::{
PayloadChecksumKind, PercentEncodingMode, SignatureLocation, SigningParams, SigningSettings,
UriPathNormalizationMode,
};
pub use sign::{sign, SignableBody, SignableRequest};