Module aws_sigv4::http_request
source · Available on crate feature
sign-http
only.Expand description
Utilities to sign HTTP requests.
§Example: Signing an HTTP request
Note: This requires http0-compat
to be enabled.
use aws_smithy_runtime_api::client::identity::Identity;
#[cfg(feature = "http1")]
fn test() -> Result<(), aws_sigv4::http_request::SigningError> {
use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest};
use aws_sigv4::sign::v4;
use http0;
use std::time::SystemTime;
// Set up information and settings for the signing
// You can obtain credentials from `SdkConfig`.
let identity = Credentials::new(
"AKIDEXAMPLE",
"wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY",
None,
None,
"hardcoded-credentials"
).into();
let signing_settings = SigningSettings::default();
let signing_params = v4::SigningParams::builder()
.identity(&identity)
.region("us-east-1")
.name("exampleservice")
.time(SystemTime::now())
.settings(signing_settings)
.build()
.unwrap()
.into();
// Convert the HTTP request into a signable request
let signable_request = SignableRequest::new(
"GET",
"https://some-endpoint.some-region.amazonaws.com",
std::iter::empty(),
SignableBody::Bytes(&[])
).expect("signable request");
let mut my_req = http::Request::new("...");
// 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_http1x(&mut my_req);
Structs§
- Represents all of the information necessary to sign an HTTP request.
- Error signing request
- Instructions for applying a signature to an HTTP request.
- HTTP-specific signing settings
Enums§
- HTTP payload checksum type
- Config value to specify how to encode the request URL when signing.
- Config value to specify whether X-Amz-Security-Token should be part of the canonical request. http://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html#temporary-security-credentials
- A signable HTTP request body
- Where to place signing values in the HTTP request
- Parameters for signing an HTTP request.
- Config value to specify whether the canonical request’s URI path should be normalized. https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
Functions§
- Produces a signature for the given
request
and returns instructions that can be used to apply that signature to an HTTP request.