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.
2 files changed
tree: 3f5e464c2fdae8b86e81d68444d9f1638965507a
  1. .github/
  2. .vscode/
  3. context/
  4. core/
  5. crypto/
  6. docs/
  7. release/
  8. reqsign/
  9. services/
  10. website/
  11. .asf.yaml
  12. .env.example
  13. .gitignore
  14. .taplo.toml
  15. AGENTS.md
  16. azure-pipelines.yml
  17. Cargo.toml
  18. CHANGELOG.md
  19. CONTRIBUTING.md
  20. LICENSE
  21. LICENSE-APACHE
  22. licenserc.toml
  23. NOTICE
  24. README.md
  25. rust-toolchain.toml
  26. rustfmt.toml
  27. SECURITY.md
  28. THREAT_MODEL.md
README.md

Apache Reqsign

Build Status Latest Version Crate Downloads

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.

Quick Start

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"] }

Option 1: Use Default Signer (Recommended)

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(())
}

Option 2: Custom Assembly

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(())
}

Customizing Default Signers

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.

More Services Examples

AWS SigV4a

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>(())

Azure Storage

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",
    ));

Cloudflare

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);

GitHub

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);

Google Cloud

use reqsign::{default_context, google};

// Default signer for Google Cloud Storage
let ctx = default_context();
let signer = google::default_signer(ctx, "storage.googleapis.com");

Aliyun OSS

use reqsign::{aliyun, default_context};

// Default signer for Aliyun OSS
let ctx = default_context();
let signer = aliyun::default_signer(ctx, "mybucket");

Aliyun Drive

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"));

Vercel Blob and Artifacts

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);

Yandex Disk

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");

Features

  • Pure Rust with minimal dependencies.
  • Tested against official SDKs and services.
  • Supported services
    • Aliyun OSS: reqsign-aliyun-oss
    • Aliyun Drive: reqsign-aliyun-drive
    • AWS shared credentials and canonicalization: reqsign-aws-core
    • AWS services (SigV4): reqsign-aws-v4
    • AWS multi-region services (SigV4a): reqsign-aws-v4a
    • Azure Storage services: reqsign-azure-storage
    • Backblaze B2 Native API: reqsign-b2
    • Baidu Netdisk: reqsign-baidu-netdisk
    • Cloudflare API (KV, D1): reqsign-cloudflare
    • Dropbox: reqsign-dropbox
    • GitHub.com: reqsign-github
    • Google services: reqsign-google
    • Huawei Cloud OBS: reqsign-huaweicloud-obs
    • HTTP Message Signatures (RFC 9421): reqsign-http-message-signatures
    • Koofr: reqsign-koofr
    • OpenStack Keystone: reqsign-openstack-keystone
    • Oracle Cloud: reqsign-oracle
    • OAuth 2.0 refresh-token support: reqsign-oauth2
    • OneDrive: reqsign-onedrive
    • Seafile: reqsign-seafile
    • Tencent COS: reqsign-tencent-cos
    • Upyun: reqsign-upyun
    • Vercel Blob and Artifacts: reqsign-vercel
    • Volcengine TOS: reqsign-volcengine-tos
    • Yandex Disk: reqsign-yandex-disk

Contributing

Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.

Getting help

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.

Acknowledgments

Inspired by:

License

Licensed under Apache License, Version 2.0.