pub enum ConnectionSecret {
Env(String),
File(PathBuf),
Literal(Redacted),
}Expand description
A connection string that never appears in a Debug print, a log line or an error.
A DSN usually carries a password. Held as a plain String in a #[derive(Debug)] config it is
one {:?} away from a log file. This type is where a connection string lives instead: a
reference to where it is (an environment variable, a file) or, where a program must, the
literal, which prints as <redacted>. The reference variants print their name, which is not
a secret.
Resolution happens at open (ConnectionSecret::resolve); the resolved value is a
Redacted that prints as <redacted> and gives up its text only through
Redacted::expose, a call a reviewer can grep for.
Variants§
Env(String)
Read the connection string from this environment variable when opening.
File(PathBuf)
Read it from this file (trailing whitespace trimmed), as a mounted secret.
Literal(Redacted)
The literal. Prefer a reference; this exists for tests and for programs that already hold the string.