Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pre-empt accidentally leaking PII in logs #74

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use crate::{config::FeatureFlags, FeatureFlag};

/// Source-agnostic representation of a user
#[derive(Clone, Debug)]
#[derive(Clone)]
pub(crate) struct User {
/// The user's first name
pub(crate) first_name: StringOrBytes,
Expand Down Expand Up @@ -37,6 +37,20 @@
}
}

impl std::fmt::Debug for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("User")
.field("first_name", &"***")
.field("last_name", &"***")
.field("email", &"***")
.field("phone", &"***")
.field("preferred_username", &"***")
.field("external_user_id", &self.external_user_id)
.field("enabled", &self.enabled)
.finish()
}
}

/// Crate-internal representation of a Zitadel user
#[derive(Clone, Debug)]
pub struct ZitadelUser {
Expand All @@ -59,7 +73,7 @@

/// Return the name to be used in logs to identify this user
pub(crate) fn log_name(&self) -> String {
format!("email={}", &self.user_data.email)
format!("external_id={}", &self.user_data.external_user_id)
}

/// Get idp link as required by Zitadel
Expand Down Expand Up @@ -108,7 +122,7 @@

impl Display for ZitadelUser {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "email={}", &self.user_data.email)
write!(f, "external_id={}", &self.user_data.external_user_id)

Check warning on line 125 in src/user.rs

View check run for this annotation

Codecov / codecov/patch

src/user.rs#L125

Added line #L125 was not covered by tests
}
}

Expand Down
Loading