Skip to content

Commit 40734a8

Browse files
authored
RUST-847 Redact Credential Debug output (#366)
1 parent 80e2485 commit 40734a8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/client/auth/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod scram;
1010
mod test;
1111
mod x509;
1212

13-
use std::{borrow::Cow, str::FromStr};
13+
use std::{borrow::Cow, fmt::Debug, str::FromStr};
1414

1515
use hmac::{Mac, NewMac};
1616
use rand::Rng;
@@ -324,7 +324,7 @@ impl FromStr for AuthMechanism {
324324
///
325325
/// Some fields (mechanism and source) may be omitted and will either be negotiated or assigned a
326326
/// default value, depending on the values of other fields in the credential.
327-
#[derive(Clone, Debug, Default, Deserialize, TypedBuilder, PartialEq)]
327+
#[derive(Clone, Default, Deserialize, TypedBuilder, PartialEq)]
328328
#[builder(field_defaults(default, setter(strip_option)))]
329329
#[non_exhaustive]
330330
pub struct Credential {
@@ -433,6 +433,14 @@ impl Credential {
433433
}
434434
}
435435

436+
impl Debug for Credential {
437+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
438+
f.debug_tuple("Credential")
439+
.field(&"REDACTED".to_string())
440+
.finish()
441+
}
442+
}
443+
436444
/// Contains the first client message sent as part of the authentication handshake.
437445
pub(crate) enum ClientFirst {
438446
Scram(ScramVersion, scram::ClientFirst),

0 commit comments

Comments
 (0)