pub struct EnvKeyProvider;Expand description
Loads encryption keys from environment variables, or from a file if
AUTH_STORAGE_ENCRYPTION_KEYS_FILE is set.
Known limitation (tracked, per CireSnave’s ruling on board item 124):
env vars and files sit on the same host as the data they protect. An
attacker with read access to the process environment or the key file
can decrypt everything this encrypts. This is accepted as a starting
point, not an endpoint – KeyProvider exists specifically so a
KMS-backed or age/sops-backed provider can replace this one later
without any caller-visible change. See docs/storage-backends.md for
the same note aimed at operators.
§Format
AUTH_STORAGE_ENCRYPTION_KEY(required unless the keys file setscurrent): the current key, base64-encoded, 32 bytes decoded.AUTH_STORAGE_ENCRYPTION_KEY_ID(optional, defaults to"1"): the id under whichAUTH_STORAGE_ENCRYPTION_KEYis recorded in new envelopes.AUTH_STORAGE_ENCRYPTION_KEYS_FILE(optional): path to a JSON file{"current": "<key_id>", "keys": {"<key_id>": "<base64 key>", ...}}for rotation – old keys stay loadable (decrypt-only in practice, sincecurrentpicks what new writes use) as long as they’re listed here. If set, this takes priority over the two env vars above. On Unix, a keys file readable by group or other triggers atracing::warn!; setAUTH_STORAGE_ENCRYPTION_STRICT_KEY_FILE_PERMISSIONS=1to make that a startup error instead. Not checked at all on Windows.- The single env var cannot rotate: it holds one key, so changing it makes every stored envelope undecryptable. Use the keys file for anything that will outlive one key; the storage factory warns when the env-var key protects data that is already encrypted.
Trait Implementations§
Source§impl KeyProvider for EnvKeyProvider
impl KeyProvider for EnvKeyProvider
Auto Trait Implementations§
impl Freeze for EnvKeyProvider
impl RefUnwindSafe for EnvKeyProvider
impl Send for EnvKeyProvider
impl Sync for EnvKeyProvider
impl Unpin for EnvKeyProvider
impl UnsafeUnpin for EnvKeyProvider
impl UnwindSafe for EnvKeyProvider
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more