feat: add SSH key passphrase field and file picker for key path

- Add ssh_key_passphrase field to ConnectionConfig model with full keyring lifecycle
- Pass passphrase to russh load_secret_key for encrypted SSH keys
- Add native file picker (FolderOpen icon) next to SSH key path input
- Add password-type input for key passphrase in connection dialog
- Make connection dialog form scrollable for short windows
- Fix alignment of key path input and browse button
- Add i18n keys (en + zh-CN)
This commit is contained in:
yavon007 committed 2026-05-03 04:39:03 +08:00
1 parent 0fdd0c1f9b
commit 58ca9a3b21
8 files changed
+60 -4

No files matched your search

@@ -6,6 +6,7 @@ use tauri::{AppHandle, Manager};
pub(super) const MAIN_PASSWORD_KEY: &str = "password";
pub(super) const SSH_PASSWORD_KEY: &str = "ssh_password";
pub(super) const SSH_KEY_PASSPHRASE_KEY: &str = "ssh_key_passphrase";
pub(super) const CONNECTION_STRING_KEY: &str = "connection_string";
const KEYRING_SERVICE: &str = "dev.dbx.connections";
@@ -103,6 +104,7 @@ pub(super) fn save_connections_to_file(
for config in configs {
persist_secret(store, &config.id, MAIN_PASSWORD_KEY, &config.password)?;
persist_secret(store, &config.id, SSH_PASSWORD_KEY, &config.ssh_password)?;
persist_secret(store, &config.id, SSH_KEY_PASSPHRASE_KEY, &config.ssh_key_passphrase)?;
persist_optional_secret(
store,
&config.id,
@@ -143,6 +145,15 @@ pub(super) fn load_connections_from_file(
needs_rewrite = true;
}
if config.ssh_key_passphrase.is_empty() {
if let Some(secret) = store.get_secret(&config.id, SSH_KEY_PASSPHRASE_KEY)? {
config.ssh_key_passphrase = secret;
}
} else {
store.set_secret(&config.id, SSH_KEY_PASSPHRASE_KEY, &config.ssh_key_passphrase)?;
needs_rewrite = true;
}
match config
.connection_string
.as_deref()
@@ -187,6 +198,7 @@ fn delete_removed_connection_secrets(
}
store.delete_secret(&config.id, MAIN_PASSWORD_KEY)?;
store.delete_secret(&config.id, SSH_PASSWORD_KEY)?;
store.delete_secret(&config.id, SSH_KEY_PASSPHRASE_KEY)?;
store.delete_secret(&config.id, CONNECTION_STRING_KEY)?;
}
Ok(())
@@ -235,6 +247,7 @@ fn sanitize_connections(configs: &[ConnectionConfig]) -> Vec<ConnectionConfig> {
.map(|mut config| {
config.password.clear();
config.ssh_password.clear();
config.ssh_key_passphrase.clear();
config.connection_string = None;
config
})
@@ -352,6 +365,7 @@ mod tests {
ssh_user: String::new(),
ssh_password: ssh_password.to_string(),
ssh_key_path: String::new(),
ssh_key_passphrase: String::new(),
ssh_expose_lan: false,
ssl: false,
connection_string: None,