Skip to content

Commit

Permalink
Obfuscate passwords in logs (#46)
Browse files Browse the repository at this point in the history
Obfuscate passwords in logs
  • Loading branch information
d1mmu-dev committed Feb 8, 2024
1 parent a5c6e93 commit b02cc31
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/containers/password.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::fmt::Formatter;
use derive_more::Display;
use serde::{Deserialize, Serializer, Serialize};
use std::ops::Deref;

/// String wrapper that serializes to 6 asterisks
#[derive(Clone, Debug, Deserialize, Display, Hash, PartialEq, Eq)]
#[derive(Clone, Deserialize, Display, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "pgsql", derive(diesel_derive_newtype::DieselNewType))]
#[cfg_attr(feature = "paperclip", derive(paperclip::actix::Apiv2Schema))]
pub struct Password(pub String);
Expand All @@ -30,3 +31,9 @@ impl From<String> for Password {
Self(value)
}
}

impl std::fmt::Debug for Password {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str("********")
}
}

0 comments on commit b02cc31

Please sign in to comment.