Merge pull request #925 from AppFlowy-IO/masked-postgres-password

fix: masked postgres password in logs
This commit is contained in:
Khor Shu Heng 2024-10-24 17:41:25 +08:00 committed by GitHub
commit 3247c8c9c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 3 deletions

View File

@ -3,7 +3,7 @@ use collab_stream::client::CONTROL_STREAM_KEY;
use infra::env_util::get_env_var;
use serde::Deserialize;
use sqlx::postgres::{PgConnectOptions, PgSslMode};
use std::str::FromStr;
use std::{fmt::Display, str::FromStr};
#[derive(Debug, Clone)]
pub struct Config {
@ -64,6 +64,17 @@ impl DatabaseSetting {
}
}
impl Display for DatabaseSetting {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let masked_pg_conn_opts = self.pg_conn_opts.clone().password("********");
write!(
f,
"DatabaseSetting {{ pg_conn_opts: {:?}, require_ssl: {}, max_connections: {} }}",
masked_pg_conn_opts, self.require_ssl, self.max_connections
)
}
}
#[derive(Debug, Clone)]
pub struct StreamSetting {
/// The key of the stream that contains control event, [CollabControlEvent].

View File

@ -4,7 +4,7 @@ use mailer::config::MailerSetting;
use secrecy::Secret;
use serde::Deserialize;
use sqlx::postgres::{PgConnectOptions, PgSslMode};
use std::str::FromStr;
use std::{fmt::Display, str::FromStr};
#[derive(Debug, Clone)]
pub struct Config {
@ -79,6 +79,17 @@ impl DatabaseSetting {
}
}
impl Display for DatabaseSetting {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let masked_pg_conn_opts = self.pg_conn_opts.clone().password("********");
write!(
f,
"DatabaseSetting {{ pg_conn_opts: {:?}, require_ssl: {}, max_connections: {} }}",
masked_pg_conn_opts, self.require_ssl, self.max_connections
)
}
}
#[derive(Debug, Clone)]
pub struct StreamSetting {
/// The key of the stream that contains control event, [CollabControlEvent].

View File

@ -115,10 +115,11 @@ pub struct DatabaseSetting {
impl Display for DatabaseSetting {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let masked_pg_conn_opts = self.pg_conn_opts.clone().password("********");
write!(
f,
"DatabaseSetting {{ pg_conn_opts: {:?}, require_ssl: {}, max_connections: {} }}",
self.pg_conn_opts, self.require_ssl, self.max_connections
masked_pg_conn_opts, self.require_ssl, self.max_connections
)
}
}