Skip to main content

Getting Started

Five minutes from an empty project to a signed AWS request. The same shape works for every provider — only the entry point differs.

1. Install​

Add the reqsign facade with the feature for each provider you need (features are additive):

cargo add reqsign --features aws
cargo add tokio --features full
cargo add http anyhow
FeatureEnables
awsAWS SigV4 (alias of aws-v4)
aws-v4aAWS SigV4a multi-region signing
azureAzure Storage
b2Backblaze B2 Native API
baidu-netdiskBaidu Netdisk
cloudflareCloudflare API (KV, D1)
dropboxDropbox
githubGitHub.com
googleGoogle Cloud
google-credential-access-boundary-client-sideClient-side CAB downscoping (implies google)
aliyunAliyun OSS
aliyun-driveAliyun Drive Open Platform
huaweicloudHuawei Cloud OBS
http-message-signaturesRFC 9421 request signatures
oauth2Shared OAuth 2.0 refresh-token grant
onedriveOneDrive
openstackOpenStack Keystone
oracleOracle Cloud
seafileSeafile
tencentTencent COS
upyunUpyun
vercelVercel Blob and Artifacts
volcengineVolcengine TOS
yandex-diskYandex Disk
fullEverything above

The default features include default-context, which wires a ready-to-use runtime (Tokio file reading, reqwest HTTP, Tokio command execution), and default-crypto, which lets default_context() bind RustCrypto when no process-wide provider is installed. Keep default-context unless you are bringing your own runtime; a custom context must bind a CryptoProvider explicitly. Requires Rust 1.87.0+.

2. Sign your first request​

This is the repository's compiled example — CI builds it on every commit:

use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
use reqsign::{aws, default_context};
// Create a default signer for S3 in us-east-1
let ctx = default_context();
let signer = aws::default_signer(ctx, "s3", "us-east-1");

// Build a request
let mut req = http::Request::builder()
.method(http::Method::GET)
.uri("https://s3.amazonaws.com/my-bucket/my-object")
.body(())
.unwrap()
.into_parts()
.0;

// Sign the request
signer.sign(&mut req, None).await?;


// Execute the request would require rebuilding with body
// In real usage, you'd use your HTTP client here
println!("Request signed successfully!");

Ok(())
}

Three things happen here:

  1. default_context() builds the default runtime context, and aws::default_signer(ctx, "s3", "us-east-1") composes it with AWS's full credential chain — environment variables, shared profiles, SSO, ECS, IMDS, and more. Reuse the same Context across multiple signers by cloning it. See Loading credentials.
  2. The request is built with the plain http crate. Reqsign signs http::request::Parts directly — there is no wrapper client to adopt.
  3. signer.sign(&mut req, None).await? mutates the request head in place, adding the Authorization header and companions. Passing Some(duration) instead selects query authentication where the provider supports it — see Presigning.

3. Run it​

AWS_ACCESS_KEY_ID=AKIDEXAMPLE \
AWS_SECRET_ACCESS_KEY=example-secret \
cargo run

The example signs the request and prints a confirmation; sending it is your HTTP client's job. Any placeholder credentials produce a structurally valid signature — the service rejects them, but the wire format is real.

Every provider, one pattern​

Swap the entry point and the rest of the code stays the same. Each entry composes that provider's own credential chain — the provider pages document exactly which sources:

ProviderEntry
AWS SigV4aws::default_signer(ctx, service, region)
AWS SigV4aaws::v4a::default_signer(ctx, service, region_set)
Azure Storageazure::default_signer(ctx)
Backblaze B2b2::default_signer(ctx)
Baidu Netdiskbaidu_netdisk::default_signer(ctx, access_token)
Cloudflarecloudflare::default_signer(ctx)
Dropboxdropbox::default_signer(ctx)
Vercel Blobvercel::default_blob_signer(ctx)
Vercel Artifactsvercel::default_artifacts_signer(ctx)
GitHubgithub::default_signer(ctx)
OneDriveonedrive::default_signer(ctx)
Google Cloudgoogle::default_signer(ctx, service)
Aliyun OSSaliyun::default_signer(ctx, bucket)
Aliyun Drivealiyun_drive::default_signer(ctx)
Huawei Cloud OBShuaweicloud::default_signer(ctx, bucket)
HTTP Message Signatures (RFC 9421)http_message_signatures::RequestSigner::new(label, components)
OpenStack Keystoneopenstack::default_signer(ctx)
Oracle Cloudoracle::default_signer(ctx)
Seafileseafile::default_signer(ctx)
Tencent COStencent::default_signer(ctx)
Upyunupyun::default_signer(ctx, bucket)
Volcengine TOSvolcengine::default_signer(ctx, region)
Yandex Diskyandex_disk::default_signer(ctx, access_token)

Aliyun Drive has no documented ambient source; replace its default provider with a static access token or refresh-token provider. OneDrive's default chain is also empty; prepend a refresh-token or static provider explicitly.

A default signer is an ordinary Signer: replace any component and keep the rest —

async fn main() -> anyhow::Result<()> {
use reqsign::aws::{self, StaticCredentialProvider};
let ctx = reqsign::default_context();
let signer = aws::default_signer(ctx.clone(), "s3", "us-east-1").with_credential_provider(
StaticCredentialProvider::new("AKIDEXAMPLE", "example-secret-key"),
);

let provider = reqsign::aws::DefaultCredentialProvider::new().push_front(
StaticCredentialProvider::new("AKIDEXAMPLE", "example-secret-key"),
);
let _custom_chain_signer =
aws::default_signer(ctx, "s3", "us-east-1").with_credential_provider(provider);

let mut req = http::Request::get("https://s3.amazonaws.com/my-bucket/my-object")
.body(())?
.into_parts()
.0;
signer.sign(&mut req, None).await?;
assert!(req.headers.contains_key("authorization"));
Ok(())
}

Where to go next​