Skip to main content

AuthyClient

Struct AuthyClient 

Source
pub struct AuthyClient { /* private fields */ }
Expand description

High-level client for programmatic vault access.

Each operation loads the vault, performs the mutation, saves it back, and appends an audit entry — mirroring the CLI handler pattern.

Implementations§

Source§

impl AuthyClient

Source

pub fn with_passphrase(passphrase: &str) -> Result<Self>

Authenticate with a passphrase.

Source

pub fn with_keyfile(keyfile_path: &str) -> Result<Self>

Authenticate with an age keyfile on disk.

Source

pub fn from_env() -> Result<Self>

Authenticate from environment variables (AUTHY_KEYFILE or AUTHY_PASSPHRASE).

This does not fall through to interactive prompts — it only reads env vars.

Source

pub fn with_actor(self, actor: impl Into<String>) -> Self

Override the actor label used in audit entries.

Source

pub fn is_initialized() -> bool

Check whether the vault has been initialized.

Source

pub fn get(&self, name: &str) -> Result<Option<String>>

Retrieve a secret by name. Returns None if not found.

Source

pub fn get_or_err(&self, name: &str) -> Result<String>

Retrieve a secret by name, returning an error if it does not exist.

Source

pub fn store(&self, name: &str, value: &str, force: bool) -> Result<()>

Store a secret. If force is false and the secret already exists, returns AuthyError::SecretAlreadyExists.

Source

pub fn remove(&self, name: &str) -> Result<bool>

Remove a secret. Returns true if the secret existed.

Source

pub fn rotate(&self, name: &str, new_value: &str) -> Result<u32>

Rotate a secret to a new value. Returns the new version number. The secret must already exist.

Source

pub fn list(&self, scope: Option<&str>) -> Result<Vec<String>>

List secret names, optionally filtered by a policy scope.

Source

pub fn init_vault(&self) -> Result<()>

Initialize a new vault. The vault must not already exist.

Source

pub fn audit_entries(&self) -> Result<Vec<AuditEntry>>

Read all audit entries from the log.

Source

pub fn verify_audit_chain(&self) -> Result<(usize, bool)>

Verify the integrity of the audit chain. Returns (entry_count, valid).

Source

pub fn test_policy(&self, scope: &str, secret_name: &str) -> Result<bool>

Test whether a policy allows access to a secret. Returns true if allowed, false if denied.

Source

pub fn create_policy( &self, name: &str, allow: Vec<String>, deny: Vec<String>, description: Option<&str>, run_only: bool, ) -> Result<()>

Create a new policy in the vault.

Auto Trait Implementations§

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