hubcio commented on code in PR #2931:
URL: https://github.com/apache/iggy/pull/2931#discussion_r2936627777


##########
core/common/src/types/configuration/auth_config/connection_string.rs:
##########
@@ -115,7 +116,7 @@ impl<T: ConnectionStringOptions + Default> 
ConnectionString<T> {
             server_address: server_address.to_owned(),
             auto_login: AutoLogin::Enabled(Credentials::UsernamePassword(
                 username.to_owned(),
-                password.to_owned(),
+                SecretString::from(password.to_owned()),

Review Comment:
   cant you just use SecretString::from(pat_token)? `SecretString` implements 
`From<&str>`



##########
core/connectors/runtime/src/api/config.rs:
##########


Review Comment:
   any reason why this is still plain `String` while `RuntimeContext.api_key` 
is `SecretString`?



##########
core/server/src/state/system.rs:
##########


Review Comment:
   preexisting issue: if anyone logs UserState with {:?}, the bcrypt/argon2 
hash leaks. The Display impl is safe (doesn't include it), but Debug is not.



##########
core/common/src/utils/serde_secret.rs:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//! Serde serialization helpers for `SecretString` fields.
+//!
+//! `SecretString` intentionally does not implement `Serialize` to prevent
+//! accidental secret exposure. These helpers are for fields that **must** be
+//! serialized (e.g., wire protocol payloads, persisted TOML configs, API
+//! responses that already expose credentials by design).
+//!
+//! Usage:
+//! ```ignore
+//! #[serde(serialize_with = "crate::utils::serde_secret::serialize_secret")]
+//! pub password: SecretString,
+//! ```
+//!
+//! Do **not** add `serialize_with` to fields that should remain redacted in
+//! serialized output — rely on `SecretString`'s default behavior instead.
+
+use secrecy::{ExposeSecret, SecretString};
+
+pub fn serialize_secret<S: serde::Serializer>(
+    secret: &SecretString,
+    serializer: S,
+) -> Result<S::Ok, S::Error> {
+    serializer.serialize_str(secret.expose_secret())
+}
+
+pub fn serialize_optional_secret<S: serde::Serializer>(
+    secret: &Option<SecretString>,
+    serializer: S,
+) -> Result<S::Ok, S::Error> {
+    match secret {
+        Some(s) => serializer.serialize_some(s.expose_secret()),
+        None => serializer.serialize_none(),
+    }
+}

Review Comment:
   please test this



##########
core/common/src/types/user/user_identity_info.rs:
##########
@@ -35,10 +36,19 @@ pub struct IdentityInfo {
 /// It consists of the following fields:
 /// - `token`: the value of token.
 /// - `expiry`: the expiry of token.
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize)]
 pub struct TokenInfo {
     /// The value of token.
     pub token: String,

Review Comment:
   critical issue: you overidden debug, but users of this token can still leak 
this via `Display`, `Serialize` or cloning into log contexts
   
   same issue in `RawPersonalAccessToken.token`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to