Add SecretString type to config
This commit is contained in:
@@ -7,6 +7,34 @@ use serde::Deserialize;
|
||||
/// (Secure cookies can't be set over HTTP. Rough assumption: development is done over HTTP)
|
||||
const DEFAULT_COOKIES_SECURE: bool = cfg!(not(debug_assertions));
|
||||
|
||||
// Simple newtype to avoid showing secrets with `Debug` / `Display`
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct SecretString(String);
|
||||
|
||||
impl SecretString {
|
||||
pub fn expose(&self) -> &String {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for SecretString {
|
||||
fn from(s: String) -> Self {
|
||||
Self(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SecretString {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "*****")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SecretString {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "*****")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct AuthConfig {
|
||||
pub open_signup: bool,
|
||||
|
||||
Reference in New Issue
Block a user