feat: add support for direct password configuration in server settings

Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-15 20:38:09 -03:00
parent 7ad10f92e8
commit 0e88a177b3

View File

@@ -25,6 +25,7 @@ pub struct ServerConfig {
pub address: Option<String>, pub address: Option<String>,
pub port: Option<u16>, pub port: Option<u16>,
pub password_file: Option<PathBuf>, pub password_file: Option<PathBuf>,
pub password: Option<String>,
} }
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
@@ -154,9 +155,10 @@ impl Config {
Ok(xdg_dirs.get_config_home().join("config.yml")) Ok(xdg_dirs.get_config_home().join("config.yml"))
} }
/// Read password from password_file if configured /// Read password from password_file or directly from config if configured
pub fn get_server_password(&self) -> Result<Option<String>> { pub fn get_server_password(&self) -> Result<Option<String>> {
if let Some(server) = &self.server { if let Some(server) = &self.server {
// First check for password_file
if let Some(password_file) = &server.password_file { if let Some(password_file) = &server.password_file {
debug!("CONFIG: Reading password from file: {:?}", password_file); debug!("CONFIG: Reading password from file: {:?}", password_file);
let password = fs::read_to_string(password_file) let password = fs::read_to_string(password_file)
@@ -165,6 +167,12 @@ impl Config {
.to_string(); .to_string();
return Ok(Some(password)); return Ok(Some(password));
} }
// Fall back to direct password field
if let Some(password) = &server.password {
debug!("CONFIG: Using password from config");
return Ok(Some(password.clone()));
}
} }
Ok(None) Ok(None)
} }