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
| Feature | Enables |
|---|---|
aws | AWS SigV4 (alias of aws-v4) |
aws-v4a | AWS SigV4a multi-region signing |
azure | Azure Storage |
b2 | Backblaze B2 Native API |
baidu-netdisk | Baidu Netdisk |
cloudflare | Cloudflare API (KV, D1) |
dropbox | Dropbox |
github | GitHub.com |
google | Google Cloud |
google-credential-access-boundary-client-side | Client-side CAB downscoping (implies google) |
aliyun | Aliyun OSS |
aliyun-drive | Aliyun Drive Open Platform |
huaweicloud | Huawei Cloud OBS |
http-message-signatures | RFC 9421 request signatures |
oauth2 | Shared OAuth 2.0 refresh-token grant |
onedrive | OneDrive |
openstack | OpenStack Keystone |
oracle | Oracle Cloud |
seafile | Seafile |
tencent | Tencent COS |
upyun | Upyun |
vercel | Vercel Blob and Artifacts |
volcengine | Volcengine TOS |
yandex-disk | Yandex Disk |
full | Everything 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:
default_context()builds the default runtime context, andaws::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 sameContextacross multiple signers by cloning it. See Loading credentials.- The request is built with the plain
httpcrate. Reqsign signshttp::request::Partsdirectly — there is no wrapper client to adopt. signer.sign(&mut req, None).await?mutates the request head in place, adding theAuthorizationheader and companions. PassingSome(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:
| Provider | Entry |
|---|---|
| AWS SigV4 | aws::default_signer(ctx, service, region) |
| AWS SigV4a | aws::v4a::default_signer(ctx, service, region_set) |
| Azure Storage | azure::default_signer(ctx) |
| Backblaze B2 | b2::default_signer(ctx) |
| Baidu Netdisk | baidu_netdisk::default_signer(ctx, access_token) |
| Cloudflare | cloudflare::default_signer(ctx) |
| Dropbox | dropbox::default_signer(ctx) |
| Vercel Blob | vercel::default_blob_signer(ctx) |
| Vercel Artifacts | vercel::default_artifacts_signer(ctx) |
| GitHub | github::default_signer(ctx) |
| OneDrive | onedrive::default_signer(ctx) |
| Google Cloud | google::default_signer(ctx, service) |
| Aliyun OSS | aliyun::default_signer(ctx, bucket) |
| Aliyun Drive | aliyun_drive::default_signer(ctx) |
| Huawei Cloud OBS | huaweicloud::default_signer(ctx, bucket) |
| HTTP Message Signatures (RFC 9421) | http_message_signatures::RequestSigner::new(label, components) |
| OpenStack Keystone | openstack::default_signer(ctx) |
| Oracle Cloud | oracle::default_signer(ctx) |
| Seafile | seafile::default_signer(ctx) |
| Tencent COS | tencent::default_signer(ctx) |
| Upyun | upyun::default_signer(ctx, bucket) |
| Volcengine TOS | volcengine::default_signer(ctx, region) |
| Yandex Disk | yandex_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
- Wire up credentials your way: Loading credentials.
- Hand out URLs instead of headers: Presigning.
- Understand the pieces you just used: Architecture.
- Check what your provider supports: provider matrix.