Expand description
Signing API requests without effort.
§Example
use anyhow::Result;
use reqsign::AwsConfig;
use reqsign::AwsDefaultLoader;
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 client = Client::new();
let config = AwsConfig::default().from_profile().from_env();
let loader = AwsDefaultLoader::new(client.clone(), config);
let signer = AwsV4Signer::new("s3", "us-east-1");
// 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
let credential = loader.load().await?.unwrap();
signer.sign(&mut req, &credential)?;
// Sending already signed request.
let resp = client.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§
- Aliyun
Config - Config carries all the configuration for Aliyun services.
- Aliyun
Credential - Credential that holds the access_key and secret_key.
- Aliyun
Loader - Loader will load credential from different methods.
- Aliyun
OssSigner - Singer for Aliyun OSS.
- AwsAssume
Role Loader - AssumeRoleLoader will load credential via assume role.
- AwsConfig
- Config for aws services.
- AwsCredential
- Credential that holds the access_key and secret_key.
- AwsDefault
Loader - CredentialLoader will load credential from different methods.
- AwsV4
Signer - Singer that implement AWS SigV4.
- Azure
Storage Config - Config carries all the configuration for Azure Storage services.
- Azure
Storage Loader - Loader will load credential from different methods.
- Azure
Storage Signer - Singer that implement Azure Storage Shared Key Authorization.
- Google
Credential - A Google API credential file.
- Google
Credential Loader - CredentialLoader will load credential from different methods.
- Google
Signer - Singer that implement Google OAuth2 Authentication.
- Google
Token - Token is the authentication methods used by google services.
- Google
Token Loader - TokenLoader will load token from different methods.
- Huaweicloud
ObsConfig - Config carries all the configuration for Huawei Cloud OBS services.
- Huaweicloud
ObsCredential - Credential for obs.
- Huaweicloud
ObsCredential Loader - CredentialLoader will load credential from different methods.
- Huaweicloud
ObsSigner - Singer that implement Huawei Cloud Object Storage Service Authorization.
- OCIAPI
KeySigner - Singer for Oracle Cloud Infrastructure using API Key.
- OCIConfig
- Config carries all the configuration for Oracle services. will be loaded from default config file ~/.oci/config
- OCICredential
- Credential that holds the API private key. private_key_path is optional, because some other credential will be added later
- OCILoader
- Loader will load credential from different methods.
- Tencent
CosConfig - Config carries all the configuration for Tencent COS services.
- Tencent
CosCredential - Credential for cos.
- Tencent
CosCredential Loader - CredentialLoader will load credential from different methods.
- Tencent
CosSigner - Singer for Tencent COS.
Enums§
- Azure
Storage Credential - Credential that holds the access_key and secret_key.
Traits§
- AwsCredential
Load - Loader trait will try to load credential from different sources.
- Google
Token Load - Loader trait will try to load credential from different sources.