wasmcloud_host/
secrets.rs

1//! Module with structs for use in managing and accessing secrets in a wasmCloud lattice
2use std::collections::HashMap;
3
4use secrecy::SecretBox;
5use wasmcloud_runtime::capability::secrets::store::SecretValue;
6
7/// A trait for fetching secrets from a secret store. This is used by the host to fetch secrets
8/// from a configured secret store.
9///
10/// By default, this implementation does nothing and returns an empty map. This is useful for
11/// testing or when no secret fetching is required.
12#[async_trait::async_trait]
13pub trait SecretsManager: Send + Sync {
14    /// Fetch secrets by name from the secret store. Additional information is provided that can be
15    /// sent to the secret store, such as the entity JWT and host JWT, for additional validation.
16    async fn fetch_secrets(
17        &self,
18        _secret_names: Vec<String>,
19        _entity_jwt: Option<&String>,
20        _host_jwt: &str,
21        _application: Option<&String>,
22    ) -> anyhow::Result<HashMap<String, SecretBox<SecretValue>>> {
23        Ok(HashMap::with_capacity(0))
24    }
25}
26
27/// A default implementation of the SecretsManager trait that has no secrets.
28#[derive(Default)]
29pub struct DefaultSecretsManager {}
30impl SecretsManager for DefaultSecretsManager {}