fix(azure): make provider credential Debug output fully opaque (#1058) ## Problem `ClientSecretCredentialProvider` and `ClientCertificateCredentialProvider` derived `Debug`. Credential-chain diagnostics format providers, so an explicitly configured client secret or certificate password could appear in logs. ## Change - Replace both derived implementations with explicit `Debug` output. - Keep tenant ID, client ID, authority host, and certificate path visible. - Render a configured client secret or certificate password as the fixed `REDACTED` marker. The marker is independent of the value, so long, short, and multibyte values contribute no original bytes or prefix/suffix. - Preserve `Some`/`None` presence. Neither provider stores certificate or private-key bytes. - Leave Entra expiry conversion sites and tests unchanged. ## Tests - Exact-output synthetic Debug tests for both providers over long ASCII, short ASCII, and multibyte values. - Existing normal and unrepresentable Entra expiry tests retained. - Local package verification: lib/doc/integration tests, clippy with `-D warnings`, and wasm host check. This description contains no live credentials or raw diagnostic logs.
Signing API requests without effort.
Most APIs are simple, but they can become complicated when hidden behind complex abstractions. reqsign brings the simple API back: build, sign, send.
Add reqsign to your Cargo.toml with the feature of the service you sign for. The example also needs anyhow, http, and tokio:
[dependencies] reqsign = { version = "0.21", features = ["aws"] } anyhow = "1" http = "1" tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
The simplest way to use reqsign is with the default signers provided by each service:
use anyhow::Result; use reqsign::{aws, default_context}; #[tokio::main] async fn main() -> Result<()> { // Create a default runtime context (HTTP client, file reader, OS env, command execution). // It binds RustCrypto when no process-wide provider is installed. let ctx = default_context(); // Create a default signer for S3 in us-east-1 using the supplied context let signer = aws::default_signer(ctx, "s3", "us-east-1"); // Build your request let mut req = http::Request::builder() .method("GET") .uri("https://s3.amazonaws.com/testbucket") .body(()) .unwrap() .into_parts() .0; // Sign the request signer.sign(&mut req, None).await?; // Send the request with your preferred HTTP client println!("Request has been signed!"); Ok(()) }
For more control over the components, you can manually assemble the signer. This example uses the AWS signer and native context crates directly:
[dependencies] reqsign = "0.21" reqsign-aws-v4 = "4" reqsign-file-read-tokio = "4" reqsign-http-send-reqwest = "5" anyhow = "1" http = "1" tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
use anyhow::Result; use reqsign::{Context, RustCryptoProvider, Signer}; use reqsign_aws_v4::{DefaultCredentialProvider, RequestSigner}; use reqsign_file_read_tokio::TokioFileRead; use reqsign_http_send_reqwest::ReqwestHttpSend; #[tokio::main] async fn main() -> Result<()> { // Build your own context with specific implementations. // A bare Context starts unbound, so bind the provider explicitly. let ctx = Context::new() .with_crypto(RustCryptoProvider::new()) .with_file_read(TokioFileRead) .with_http_send(ReqwestHttpSend::default()) .with_env(reqsign::OsEnv); // Configure credential provider let credential_provider = DefaultCredentialProvider::new(); // Configure request signer for S3 let request_signer = RequestSigner::new("s3", "us-east-1"); // Assemble the signer let signer = Signer::new(ctx, credential_provider, request_signer); // Build and sign the request let mut req = http::Request::builder() .method("GET") .uri("https://s3.amazonaws.com/testbucket") .body(()) .unwrap() .into_parts() .0; // Sign the request signer.sign(&mut req, None).await?; println!("Request has been signed!"); Ok(()) }
You can also customize the default signers using the with_* methods:
use reqsign::{aws, default_context}; use reqsign_aws_v4::StaticCredentialProvider; // Start with default signer and customize specific components let ctx = default_context(); let signer = aws::default_signer(ctx, "s3", "us-east-1") .with_credential_provider(StaticCredentialProvider::new( "my-access-key", "my-secret-key", ));
For server applications that already hold an OIDC assertion, see Caller-provided subject tokens.
use reqsign::aws::v4a::{SigningRegionSet, default_signer}; use reqsign::default_context; let ctx = default_context(); let region_set = SigningRegionSet::new("us-east-1,us-west-2")?; let signer = default_signer(ctx, "s3", region_set); # Ok::<(), reqsign_core::Error>(())
use reqsign::{azure, default_context}; let ctx = default_context(); // Default signer for Azure Storage let signer = azure::default_signer(ctx.clone()); // With custom credentials use reqsign_azure_storage::StaticCredentialProvider; let signer = azure::default_signer(ctx) .with_credential_provider(StaticCredentialProvider::new_shared_key( "account-name", "account-key", ));
use reqsign::{cloudflare, default_context}; // Reads CLOUDFLARE_API_TOKEN. The account, database, and namespace IDs stay // in the request URL that you build. let ctx = default_context(); let signer = cloudflare::default_signer(ctx);
use reqsign::{default_context, github}; // Reads GH_TOKEN/GITHUB_TOKEN, then the GitHub CLI, then falls back to // anonymous access for public resources. let ctx = default_context(); let signer = github::default_signer(ctx);
use reqsign::{default_context, google}; // Default signer for Google Cloud Storage let ctx = default_context(); let signer = google::default_signer(ctx, "storage.googleapis.com");
use reqsign::{aliyun, default_context}; // Default signer for Aliyun OSS let ctx = default_context(); let signer = aliyun::default_signer(ctx, "mybucket");
use reqsign::{aliyun_drive, default_context}; // Aliyun Drive has no ambient credential contract. Supply an explicit provider. let ctx = default_context(); let signer = aliyun_drive::default_signer(ctx) .with_credential_provider(aliyun_drive::StaticCredentialProvider::new("access-token"));
use reqsign::{default_context, vercel}; let ctx = default_context(); // Reads BLOB_READ_WRITE_TOKEN. let blob_signer = vercel::default_blob_signer(ctx.clone()); // Reads TURBO_TOKEN, then VERCEL_ARTIFACTS_TOKEN. let artifacts_signer = vercel::default_artifacts_signer(ctx);
use reqsign::{default_context, yandex_disk}; // Yandex Disk has no documented automatic token source; pass the OAuth token explicitly. let ctx = default_context(); let signer = yandex_disk::default_signer(ctx, "yandex-disk-oauth-token");
reqsign-aliyun-ossreqsign-aliyun-drivereqsign-aws-corereqsign-aws-v4reqsign-aws-v4areqsign-azure-storagereqsign-b2reqsign-baidu-netdiskreqsign-cloudflarereqsign-dropboxreqsign-githubreqsign-googlereqsign-huaweicloud-obsreqsign-http-message-signaturesreqsign-koofrreqsign-openstack-keystonereqsign-oraclereqsign-oauth2reqsign-onedrivereqsign-seafilereqsign-tencent-cosreqsign-upyunreqsign-vercelreqsign-volcengine-tosreqsign-yandex-diskCheck out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.
Submit issues for bug report or asking questions in discussion.
Join the development mailing list for project discussions and release votes. Subscribe before posting, or browse the archives.
Inspired by:
Licensed under Apache License, Version 2.0.