Skip to main content

Secrets

Struct Secrets 

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

Owns the KMS and the audit sink; hands out per-store handles.

Implementations§

Source§

impl Secrets

Source

pub fn new(kms: Arc<dyn Kms>) -> Self

Wires the KMS. The default audit sink logs one line per access through tracing; #41 replaces it with the append-only log.

Source

pub fn with_audit(self, audit: Arc<dyn Audit>) -> Self

Source

pub fn global(&self, db: Arc<dyn Database>, _proof: HarnessOnly) -> SecretStore

The control database’s store: connection strings and platform keys. Needs a HarnessOnly, which module code cannot build.

The proof is the whole gate, so the call is unreachable without one — a module holding a Secrets and a Database still cannot open the global store:

ⓘ
fn reach_the_control_database(secrets: &Secrets, db: Arc<dyn Database>) {
    // No second argument can be constructed here.
    let _global = secrets.global(db);
}

The tenant store, which is what a module is actually given, needs no proof at all:

fn a_module_reaches_its_own_store(secrets: &Secrets, db: Arc<dyn Database>) {
    let _mine = secrets.tenant("acme", db).expect("an ordinary tenant id");
}
Source

pub fn tenant( &self, tenant: &str, db: Arc<dyn Database>, ) -> Result<SecretStore, SecretsError>

One tenant’s store, in that tenant’s own database. This is what a module is given.

The id becomes the row stamp and the AAD verbatim, so it is checked here rather than taken on trust.

§Errors

SecretsError::Invalid when the id is "global": that names the control plane’s store, which only Secrets::global’s proof may open — a tenant store stamped global would be indistinguishable from it, and the proof would gate nothing. Also when the id is empty or whitespace: a store stamped with nothing is nobody’s, invisible to every store. Surrounding whitespace is preserved, not trimmed — " acme " is stamped verbatim and names a different store than acme.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more