Skip to main content

Vault

Struct Vault 

Source
pub struct Vault {
    pub paths: VaultPaths,
}

Fields§

§paths: VaultPaths

Implementations§

Source§

impl Vault

Source

pub fn open(root: &Path) -> Result<Self, VaultError>

Open a vault rooted at the given directory.

Source

pub fn init(root: &Path) -> Result<Self, VaultError>

Initialize a new vault in the given directory.

Source

pub fn add_agent(&self, name: &str) -> Result<PathBuf, VaultError>

Add a new agent to the vault.

Source

pub fn set_secret( &self, secret_path: &str, value: &str, group: &str, expires: Option<DateTime<Utc>>, extra_agents: Option<&[String]>, ) -> Result<(), VaultError>

Set (create or update) a secret. extra_agents allows encrypting for specific agents beyond the group members.

Source

pub fn pull(&self) -> Result<(), VaultError>

Pull latest from git (best-effort, silently skips if no remote).

Source

pub fn get_secret( &self, secret_path: &str, key_path: &Path, ) -> Result<SecretString, VaultError>

Get (decrypt) a secret using the provided identity key.

Source

pub fn list_agents(&self) -> Result<Vec<(String, Vec<String>)>, VaultError>

List all agents in the vault.

Source

pub fn list_secrets( &self, group_filter: Option<&str>, ) -> Result<Vec<SecretMetadata>, VaultError>

List all secrets, optionally filtered by group.

Source

pub fn grant_agent( &self, agent_name: &str, group_name: &str, ) -> Result<Vec<String>, VaultError>

Grant an agent access to a group. Re-encrypts all secrets in that group.

Source

pub fn revoke_agent( &self, agent_name: &str, group_name: &str, ) -> Result<Vec<String>, VaultError>

Revoke an agent’s access to a group. Re-encrypts all secrets in that group. Returns the list of secret paths that were re-encrypted.

Source

pub fn remove_agent(&self, name: &str) -> Result<Vec<String>, VaultError>

Remove an agent from the vault entirely. Re-encrypts all secrets the agent had access to, removes agent files. Returns the list of groups the agent belonged to (for rotation warnings).

Source

pub fn recover_agent(&self, name: &str) -> Result<PathBuf, VaultError>

Recover an agent: decrypt escrow, generate new keypair, re-encrypt secrets, new escrow. Returns the path to the new private key.

Source

pub fn restore_agent( &self, name: &str, to_path: &Path, ) -> Result<(), VaultError>

Restore an agent’s original private key from escrow. Writes the decrypted key to the specified path.

Source

pub fn check(&self) -> Result<Vec<CheckIssue>, VaultError>

Audit the vault for issues.

Source

pub fn resolve_identity_key( key_flag: Option<&str>, ) -> Result<PathBuf, VaultError>

Resolve the identity key to use for decryption. Priority: –key flag > AGENT_VAULT_KEY env > ~/.agent-vault/owner.key

AGENT_VAULT_KEY supports both file paths and raw key strings (starting with AGE-SECRET-KEY-).

Auto Trait Implementations§

§

impl Freeze for Vault

§

impl RefUnwindSafe for Vault

§

impl Send for Vault

§

impl Sync for Vault

§

impl Unpin for Vault

§

impl UnsafeUnpin for Vault

§

impl UnwindSafe for Vault

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V