Skip to main content

SecretsManager

Trait SecretsManager 

Source
pub trait SecretsManager: Send + Sync {
    // Required methods
    fn get_secret(&self, name: &str, secret_type: &str) -> Option<SecretEntry>;
    fn list_secrets(&self, secret_type: Option<&str>) -> Vec<SecretEntry>;
    fn remove_secret(&self, name: &str, secret_type: &str) -> bool;
}
Expand description

Trait for accessing DuckDB’s secrets management system.

Extensions implement this trait to provide a safe Rust interface over DuckDB’s native CREATE SECRET / DROP SECRET storage. A typical implementation wraps DuckDB’s C API or maintains an in-memory cache synchronized with the DuckDB catalog.

§Thread safety

Implementations must be safe to call from multiple threads. DuckDB may invoke extension callbacks concurrently.

§Security

Implementations should:

  • Never log secret field values (use SecretEntry::field_keys for diagnostics).
  • Ensure that remove_secret zeroizes the secret data, not just removes the reference.
  • Minimize the lifetime of SecretEntry clones.

Required Methods§

Source

fn get_secret(&self, name: &str, secret_type: &str) -> Option<SecretEntry>

Retrieves a secret by name and type.

Returns None if no matching secret exists.

Source

fn list_secrets(&self, secret_type: Option<&str>) -> Vec<SecretEntry>

Lists all secrets, optionally filtered by type.

If secret_type is None, all secrets are returned.

§Security note

The returned entries contain full secret values. Callers should avoid storing or logging the result. For diagnostics, iterate and use SecretEntry::field_keys instead of SecretEntry::get_field.

Source

fn remove_secret(&self, name: &str, secret_type: &str) -> bool

Removes a secret by name and type.

Returns true if the secret was found and removed, false otherwise. Implementations should zeroize the secret data before deallocation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§