Skip to main content

SecretStore

Struct SecretStore 

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

One store: one database, one StoreId, one data key.

Implementations§

Source§

impl SecretStore

Source

pub async fn rotate_dek( &self, actor: &Actor, plan: bool, ) -> Result<RotationReport, SecretsError>

Rotates this store’s data key: a new key becomes active, every live secret version is re-encrypted under it, and the old key is retired once nothing references it.

Reads keep working throughout, because each secret row names the key that sealed it and the old key row stays until the end. A rotation interrupted half way leaves a store whose secrets are split across two keys, which is a valid state: running it again finishes the job.

§Errors

SecretsError. The attempt is audited either way.

Source

pub async fn rewrap( &self, actor: &Actor, plan: bool, ) -> Result<RewrapReport, SecretsError>

Re-wraps every data key under the master key’s current material, without touching a single secret. After a KMS rotates its key material in place, old wrapped keys still unwrap; this makes sure none of them depends on the old material any more.

§Errors

SecretsError. The attempt is audited either way.

Source§

impl SecretStore

Source

pub fn id(&self) -> &StoreId

Source

pub async fn put( &self, name: &str, value: &SecretBytes, actor: &Actor, ) -> Result<Version, SecretsError>

Writes a new version of name and returns it. Versions are monotonic per name and start at 1; a value is never overwritten, because the previous version is what a rollback needs and what the audit log refers to.

§Errors

SecretsError, and the attempt is audited either way.

Source

pub async fn get( &self, name: &str, actor: &Actor, ) -> Result<Option<SecretBytes>, SecretsError>

The latest version of name that has not been deleted, or None.

§Errors

SecretsError::NotAuthentic when the row does not match the context it was sealed with, and otherwise as SecretStore::put.

Source

pub async fn list(&self, actor: &Actor) -> Result<Vec<SecretMeta>, SecretsError>

Every secret’s latest version: names and versions, never values.

§Errors

As SecretStore::put.

Source

pub async fn delete( &self, name: &str, actor: &Actor, ) -> Result<(), SecretsError>

Soft-deletes every version of name. The rows stay, so the audit trail and any restore keep something to refer to; the value is no longer readable through SecretStore::get.

§Errors

As SecretStore::put.

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