This document defines the repository's authoritative public API design for all DefaultCredentialProvider types.
Implementations that do not match this document should be treated as legacy debt. New code, reviews, and refactors must follow this document.
configure_* patch-style APIs from the public API.DefaultCredentialProvider API uniform across services.Every service-level default provider exposes the same product-level API:
DefaultCredentialProvider::new() DefaultCredentialProvider::builder() DefaultCredentialProvider::with_chain(chain) DefaultCredentialProvider::push_front(provider) impl Default for DefaultCredentialProvider
new() creates the documented default chain for that service.default() is identical to new().builder() returns a builder pre-populated with the documented default slots.with_chain(chain) bypasses all default-chain assembly logic.push_front(provider) prepends a high-priority provider in front of the documented default chain.Every DefaultCredentialProviderBuilder exposes:
DefaultCredentialProviderBuilder::new() DefaultCredentialProviderBuilder::default() .build()
For each supported provider slot, the builder exposes exactly two primary methods:
.env(provider) .no_env()
The same pattern applies to all other slots:
.profile(provider) .no_profile() .sso(provider) .no_sso() .imds(provider) .no_imds()
configure_*.disable_*(bool).A service may expose a narrowly scoped convenience method when one logical input applies to multiple provider slots. Such a method must:
no_slot().For AWS V4, with_profile(profile) applies the explicit profile to the profile, sso, and process slots. On wasm32, it applies only to the available profile slot.
Each builder slot should be represented as:
Option<T>
with this meaning:
Some(T::default()): slot enabled with the default provider configurationSome(custom): slot enabled with a custom provider configurationNone: slot removed from the chainThis implies:
DefaultCredentialProviderBuilder::default() initializes all documented default slots to Some(T::default())..no_env() sets env to None..env(provider) sets env to Some(provider).build() pushes only Some(...) slots and skips None.No separate enabled flag is needed.
Use provider-concept names without the CredentialProvider suffix.
Examples:
envprofilessoprocessecsimdsweb_identityoidcconfig_filevm_metadataDo not collapse distinct concepts under a vague shared name.
Examples:
web_identity(...) over assume_role(...) when the slot is actually AssumeRoleWithWebIdentityCredentialProvider.oidc(...) over assume_role(...) when the slot is specifically OIDC-based.let provider = DefaultCredentialProvider::builder() .no_env() .profile(ProfileCredentialProvider::new().with_profile("prod")) .no_imds() .build();
Expected slots:
envprofilessoweb_identityprocessecsimdslet provider = DefaultCredentialProvider::builder() .env(EnvCredentialProvider::new()) .no_oidc() .build();
Expected slots:
envoidclet provider = DefaultCredentialProvider::builder() .no_env() .web_identity(AssumeRoleWithWebIdentityCredentialProvider::new()) .build();
Expected slots:
envweb_identityWhen changing an existing service:
configure_* methods.disable_*(bool) methods.Some(T::default()) for documented default slots.slot(provider) and no_slot() methods for every supported slot.no_slot() truly removes the provider from the chain.with_chain or push_front; those remain the escape hatch for advanced composition.