Expand description
Signing API requests without effort.
Example
use anyhow::Result;
use reqsign::AwsConfigLoader;
use reqsign::AwsV4Signer;
use reqwest::Client;
use reqwest::Request;
use reqwest::Url;
#[tokio::main]
async fn main() -> Result<()> {
// Signer can load region and credentials from environment by default.
let signer = AwsV4Signer::builder()
.config_loader(AwsConfigLoader::with_loaded())
.service("s3")
.build()?;
// Construct request
let url = Url::parse("https://s3.amazonaws.com/testbucket")?;
let mut req = reqwest::Request::new(http::Method::GET, url);
// Signing request with Signer
signer.sign(&mut req)?;
// Sending already signed request.
let resp = Client::new().execute(req).await?;
println!("resp got status: {}", resp.status());
Ok(())
}
Available Services
- Aliyun OSS for Aliyun OSS.
- AWS SigV4 for AWS services like S3.
- Azure Storage for Azure Storage services like Azure Blob Service.
- Google for All google cloud services like Google Cloud Storage Service.
- Huawei Cloud OBS for Huawei Cloud Object Storage Service (OBS).
Features
reqsign support http::Request
by default. Other request types support are hided
under feature gates to reduce dependencies.
reqwest_request
: Enable to support signingreqwest::Request
reqwest_blocking_request
: Enable to support signingreqwest::blocking::Request
Structs
- Config carries all the configuration for Aliyun services.
- Credential that holds the access_key and secret_key.
- Loader will load credential from different methods.
- Singer for Aliyun OSS.
- Config for aws services.
- Credential that holds the access_key and secret_key.
- CredentialLoader will load credential from different methods.
- Singer that implement AWS SigV4.
- Config carries all the configuration for Azure Storage services.
- Loader will load credential from different methods.
- Singer that implement Azure Storage Shared Key Authorization.
- A Google API credential file.
- CredentialLoader will load credential from different methods.
- Singer that implement Google OAuth2 Authentication.
- Token is the authentication methods used by google services.
- TokenLoader will load token from different methods.
- Config carries all the configuration for Huawei Cloud OBS services.
- Credential for obs.
- CredentialLoader will load credential from different methods.
- Singer that implement Huawei Cloud Object Storage Service Authorization.
- Config carries all the configuration for Tencent COS services.
- Credential for cos.
- CredentialLoader will load credential from different methods.
- Singer for Tencent COS.
Enums
- Credential that holds the access_key and secret_key.
Traits
- Loader trait will try to load credential from different sources.
- Loader trait will try to load credential from different sources.