From e315c4ad3604a47bb3e1b00c7ae684d96e8752e5 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Wed, 6 May 2026 13:23:56 +0800 Subject: [PATCH] feat(oracle): add SYSDBA authentication support Switch oracle-rs to t8y2/oracle-rs fork with SYSDBA support. Add sysdba field to ConnectionConfig and a checkbox in the Oracle connection dialog to enable connecting as SYS with SYSDBA privileges. --- Cargo.lock | 36 +++++++++++++++++-- crates/dbx-core/Cargo.toml | 2 +- crates/dbx-core/src/connection.rs | 1 + crates/dbx-core/src/db/oracle_driver.rs | 12 +++++-- crates/dbx-core/src/models/connection.rs | 3 ++ src-tauri/src/commands/connection.rs | 2 ++ .../connection/ConnectionDialog.vue | 8 +++++ src/types/database.ts | 1 + 8 files changed, 60 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7da15178a..3fdbe213a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1553,7 +1553,7 @@ dependencies = [ "futures", "log", "mongodb", - "oracle-rs", + "oracle-rs 0.1.7", "percent-encoding", "portpicker", "redis", @@ -1590,7 +1590,7 @@ dependencies = [ "futures", "log", "mongodb", - "oracle-rs", + "oracle-rs 0.1.6", "percent-encoding", "portpicker", "redis", @@ -4510,6 +4510,38 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "oracle-rs" +version = "0.1.6" +source = "git+https://github.com/t8y2/oracle-rs?branch=main#97d99d43e3d1323f7d544db8e0fdaaa0ba95cd24" +dependencies = [ + "aes 0.8.4", + "async-trait", + "bytes", + "cbc 0.1.2", + "chrono", + "hex", + "hmac 0.12.1", + "hostname", + "indexmap 2.14.0", + "md-5", + "pbkdf2 0.12.2", + "pkcs8 0.10.2", + "rand 0.8.6", + "rustls 0.23.40", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "serde", + "serde_json", + "sha1 0.10.6", + "sha2 0.10.9", + "thiserror 1.0.69", + "tokio", + "tokio-rustls 0.26.4", + "tracing", + "webpki-roots 0.26.11", +] + [[package]] name = "oracle-rs" version = "0.1.7" diff --git a/crates/dbx-core/Cargo.toml b/crates/dbx-core/Cargo.toml index cff86f58a..b69638b4e 100644 --- a/crates/dbx-core/Cargo.toml +++ b/crates/dbx-core/Cargo.toml @@ -22,7 +22,7 @@ tiberius = { version = "0.12.3", default-features = false, features = ["tds73", reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "rustls-tls"] } futures = "0.3" mongodb = "3.2.5" -oracle-rs = "0.1" +oracle-rs = { git = "https://github.com/t8y2/oracle-rs", branch = "main" } russh = "0.60" portpicker = "0.1.1" csv = "1" diff --git a/crates/dbx-core/src/connection.rs b/crates/dbx-core/src/connection.rs index a7452c148..1c5a2983f 100644 --- a/crates/dbx-core/src/connection.rs +++ b/crates/dbx-core/src/connection.rs @@ -138,6 +138,7 @@ impl AppState { db_config.database.as_deref().unwrap_or("ORCL"), &db_config.username, &db_config.password, + db_config.sysdba, ) .await?; PoolKind::Oracle(Arc::new(tokio::sync::Mutex::new(client))) diff --git a/crates/dbx-core/src/db/oracle_driver.rs b/crates/dbx-core/src/db/oracle_driver.rs index 9262a8f83..d94b6f2e4 100644 --- a/crates/dbx-core/src/db/oracle_driver.rs +++ b/crates/dbx-core/src/db/oracle_driver.rs @@ -6,8 +6,16 @@ use crate::types::{ColumnInfo, DatabaseInfo, ForeignKeyInfo, IndexInfo, QueryRes pub type OracleClient = Connection; -pub async fn connect(host: &str, port: u16, service: &str, user: &str, pass: &str) -> Result { - let config = Config::new(host, port, service, user, pass); +pub async fn connect( + host: &str, + port: u16, + service: &str, + user: &str, + pass: &str, + sysdba: bool, +) -> Result { + let mut config = Config::new(host, port, service, user, pass); + config.sysdba = sysdba; tokio::time::timeout(connection_timeout(), Connection::connect_with_config(config)) .await .map_err(|_| format!("Oracle connection timed out ({CONNECTION_TIMEOUT_SECS}s)"))? diff --git a/crates/dbx-core/src/models/connection.rs b/crates/dbx-core/src/models/connection.rs index d726b7ab0..185ed7ea2 100644 --- a/crates/dbx-core/src/models/connection.rs +++ b/crates/dbx-core/src/models/connection.rs @@ -38,6 +38,8 @@ pub struct ConnectionConfig { #[serde(default)] pub ssl: bool, #[serde(default)] + pub sysdba: bool, + #[serde(default)] pub connection_string: Option, } @@ -277,6 +279,7 @@ mod tests { ssh_key_passphrase: String::new(), ssh_expose_lan: false, ssl: false, + sysdba: false, connection_string: None, } } diff --git a/src-tauri/src/commands/connection.rs b/src-tauri/src/commands/connection.rs index 55640fbda..e9f635420 100644 --- a/src-tauri/src/commands/connection.rs +++ b/src-tauri/src/commands/connection.rs @@ -103,6 +103,7 @@ pub async fn test_connection(state: State<'_, Arc>, config: Connection config.database.as_deref().unwrap_or("ORCL"), &config.username, &config.password, + config.sysdba, ) .await .map(|_| "Connection successful".to_string()), @@ -168,6 +169,7 @@ pub async fn connect_db(state: State<'_, Arc>, config: ConnectionConfi config.database.as_deref().unwrap_or("ORCL"), &config.username, &config.password, + config.sysdba, ) .await?; PoolKind::Oracle(std::sync::Arc::new(tokio::sync::Mutex::new(client))) diff --git a/src/components/connection/ConnectionDialog.vue b/src/components/connection/ConnectionDialog.vue index e745668a6..b8e3801b8 100644 --- a/src/components/connection/ConnectionDialog.vue +++ b/src/components/connection/ConnectionDialog.vue @@ -794,6 +794,14 @@ async function browseSshKeyPath() {

+
+ + +
+