Skip to main content

Vault

Struct Vault 

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

The secret store, as an application enables it.

Config keyMeaning
vault.resolveConfiguration roots to search for references, as an array.

Implementations§

Source§

impl Vault

Source

pub fn fake() -> FakeVault

A store that answers from an empty script — every read fails loudly.

Source

pub fn fake_with(fake: Fake) -> FakeVault

A store that answers from a script written out in advance.

Source§

impl Vault

Source

pub fn new(client: VaultClient) -> Vault

Source

pub fn from_env() -> Result<Vault>

Take the address, token and namespace from the environment, the way every other Vault and OpenBao tool does.

Source

pub fn resolving(self, root: impl Into<String>) -> Vault

Also search this configuration subtree for vault: references.

Named rather than discovered because Config cannot be enumerated, and because a resolver that walked everything would read secrets for keys nobody asked it to touch.

Source

pub fn even_over_http(self) -> Vault

Do not warn about a plain-HTTP address.

Spelled out in full because of what it means: the token goes over the wire in clear text, and a token is the whole store. Loopback addresses never warn in the first place, so this is only for a network you have decided to trust.

Source

pub fn client(&self) -> &VaultClient

Source

pub fn renewer(&self) -> &Arc<Renewer> ⓘ

The renewer this plugin registers.

Whatever issues a lease — a login, a dynamic database credential — hands it here, and it is kept alive until the application stops.

Source

pub async fn resolve(&self, config: &Config) -> Result<usize>

Swap every vault: reference in configuration for the secret it names, and say how many were replaced.

The roots come from Vault::resolving, or from vault.resolve in configuration when the builder named none — a value written in main.rs is a decision and a value in a config file is a default.

Source

pub async fn resolve_env(&self) -> Result<usize>

Swap every vault: reference in the process environment.

For an application whose secrets arrive as DATABASE_URL=vault:…. Call it before the application boots, so .env and the configuration defaults see values rather than references.

Trait Implementations§

Source§

impl Debug for Vault

Deliberately hand-written: the client’s own Debug redacts the token, and deriving here would be one refactor away from printing it.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Plugin for Vault

Source§

fn name(&self) -> &'static str

Shown by rustlavel route:list and in boot logs.
Source§

fn register(self: Box<Self>, setup: &mut Setup<'_>)

Add routes, middleware, and state.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Vault

§

impl !UnwindSafe for Vault

§

impl Freeze for Vault

§

impl Send for Vault

§

impl Sync for Vault

§

impl Unpin for Vault

§

impl UnsafeUnpin 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.