Skip to main content

SecretProvider

Trait SecretProvider 

Source
pub trait SecretProvider: Send + Sync {
    // Required method
    fn get_secret<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Available on crate feature auth only.
Expand description

Trait for retrieving secrets from an external secret management service.

Implementations are provided for AWS Secrets Manager (aws-secrets feature), Azure Key Vault (azure-keyvault feature), and GCP Secret Manager (gcp-secrets feature).

§Example

use adk_auth::secrets::SecretProvider;

async fn use_secret(provider: &dyn SecretProvider) -> Result<(), AdkError> {
    let api_key = provider.get_secret("my-api-key").await?;
    println!("retrieved secret of length {}", api_key.len());
    Ok(())
}

Required Methods§

Source

fn get_secret<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Retrieve a secret value by name.

§Errors

Returns an AdkError with the appropriate error category:

  • Unauthorized for authentication failures
  • Unavailable for network errors
  • NotFound when the secret does not exist

Implementors§