mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-22 00:01:34 +00:00
fix: mask secrets in OAuth config debug/log output (#8269)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,7 @@ pub struct EnvRefWrapper {
|
||||
///
|
||||
/// `Literal` serializes back to a plain JSON string, preserving backwards
|
||||
/// compatibility with existing consumers.
|
||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
#[cfg_attr(feature = "instance_config_schema", derive(schemars::JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
pub enum StringOrSecretRef {
|
||||
@@ -53,6 +53,16 @@ pub enum StringOrSecretRef {
|
||||
EnvRef(EnvRefWrapper),
|
||||
}
|
||||
|
||||
impl fmt::Debug for StringOrSecretRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Literal(_) => f.write_str("Literal(****)"),
|
||||
Self::SecretRef(w) => f.debug_tuple("SecretRef").field(w).finish(),
|
||||
Self::EnvRef(w) => f.debug_tuple("EnvRef").field(w).finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StringOrSecretRef {
|
||||
/// Returns the literal string value, or `None` if this is an unresolved ref.
|
||||
pub fn as_literal(&self) -> Option<&str> {
|
||||
|
||||
@@ -94,7 +94,7 @@ pub struct OAuthConfig {
|
||||
}
|
||||
|
||||
/// OAuth client credentials
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct OAuthClient {
|
||||
#[serde(default = "empty_string")]
|
||||
pub id: String,
|
||||
@@ -110,6 +110,21 @@ pub struct OAuthClient {
|
||||
pub grant_types: Vec<String>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for OAuthClient {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("OAuthClient")
|
||||
.field("id", &self.id)
|
||||
.field("secret", &"***")
|
||||
.field("display_name", &self.display_name)
|
||||
.field("allowed_domains", &self.allowed_domains)
|
||||
.field("connect_config", &self.connect_config)
|
||||
.field("login_config", &self.login_config)
|
||||
.field("tenant", &self.tenant)
|
||||
.field("grant_types", &self.grant_types)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
fn empty_string() -> String {
|
||||
"".to_string()
|
||||
}
|
||||
@@ -608,7 +623,18 @@ pub async fn refresh_token<'c>(
|
||||
.await?;
|
||||
let account = windmill_common::utils::not_found_if_none(account, "Account", &id.to_string())?;
|
||||
|
||||
refresh_token_for_account(tx, path, w_id, id, db, account, oauth_clients, http_client, connect_configs_json).await
|
||||
refresh_token_for_account(
|
||||
tx,
|
||||
path,
|
||||
w_id,
|
||||
id,
|
||||
db,
|
||||
account,
|
||||
oauth_clients,
|
||||
http_client,
|
||||
connect_configs_json,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Refresh an OAuth token given pre-fetched account info (no additional SELECT).
|
||||
|
||||
Reference in New Issue
Block a user