Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(ssh): support ssh agent auth in tunnel manager

jearhe061041e1d7f9
diff --git a/apps/desktop/src/components/connection/TunnelProfileManager.vue b/apps/desktop/src/components/connection/TunnelProfileManager.vue
index 873ff1b8a6..dbd0a7d014 100644
--- a/apps/desktop/src/components/connection/TunnelProfileManager.vue
+++ b/apps/desktop/src/components/connection/TunnelProfileManager.vue
@@ -13,6 +13,7 @@ import { useToast } from "@/composables/useToast";
import { useTunnelProfileStore } from "@/stores/tunnelProfileStore";
import { createTunnelProfile, createTunnelProfileTestGuard, tunnelProfileSummary, type TunnelProfileType } from "@/lib/connection/tunnelProfiles";
import { applySshConfigHostAliasPrefill as prefillSshConfigHostAlias } from "@/lib/connection/sshConfigHosts";
+import { applySshAuthMethod } from "@/lib/connection/sshAuthMethod";
import * as api from "@/lib/backend/api";
import type { SshConfigHostEntry, TunnelProfile } from "@/types/database";
import { translateBackendError } from "@/i18n/backend-errors";
@@ -118,15 +119,12 @@ function removeSelected() {
selectedId.value = draft.value[0]?.id || null;
}
+// Shared with the connection editor so both SSH entry points keep one single
+// auth-method <-> credential mapping (see sshAuthMethod.ts).
function updateSshAuthMethod(value: unknown) {
const profile = selectedSsh.value;
if (!profile) return;
- profile.auth_method = value === "key" ? "key" : value === "key+password" ? "key+password" : value === "none" ? "none" : "password";
- if (profile.auth_method !== "password" && profile.auth_method !== "key+password") profile.password = "";
- if (profile.auth_method !== "key" && profile.auth_method !== "key+password") {
- profile.key_path = "";
- profile.key_passphrase = "";
- }
+ applySshAuthMethod(profile, value);
}
function updateProxyType(value: unknown) {
@@ -252,6 +250,7 @@ async function testSelected() {
<SelectItem value="password">{{ t("connection.sshAuthMethodPassword") }}</SelectItem>
<SelectItem value="key">{{ t("connection.sshAuthMethodKey") }}</SelectItem>
<SelectItem value="key+password">{{ t("connection.sshAuthMethodKeyPassword") }}</SelectItem>
+ <SelectItem value="agent">{{ t("connection.sshUseAgent") }}</SelectItem>
<SelectItem value="none">{{ t("connection.sshAuthMethodNone") }}</SelectItem>
</SelectContent>
</Select>
@@ -282,6 +281,10 @@ async function testSelected() {
<span />
<p class="col-span-3 text-xs text-muted-foreground">{{ t("connection.sshAuthMethodNoneHint") }}</p>
</div>
+ <div v-if="selectedSsh.auth_method === 'agent'" class="grid grid-cols-4 items-center gap-4">
+ <Label class="text-xs">{{ t("connection.sshAgentSockPath") }}</Label>
+ <Input v-model="selectedSsh.ssh_agent_sock_path" class="col-span-3" :placeholder="t('connection.sshAgentSockPathPlaceholder')" />
+ </div>
<div class="grid grid-cols-4 items-center gap-4">
<span />
<label class="col-span-3 flex cursor-pointer items-center gap-2">
diff --git a/apps/desktop/src/lib/__tests__/connection/sshAgentTunnelProfileManager.spec.ts b/apps/desktop/src/lib/__tests__/connection/sshAgentTunnelProfileManager.spec.ts
new file mode 100644
index 0000000000..c1c12c0e21
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/connection/sshAgentTunnelProfileManager.spec.ts
@@ -0,0 +1,21 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+
+const managerSource = readFileSync(new URL("../../../components/connection/TunnelProfileManager.vue", import.meta.url), "utf8");
+
+describe("SSH agent tunnel profile form", () => {
+ it("offers the same SSH agent login method as the connection editor", () => {
+ expect(managerSource).toContain('<SelectItem value="agent">{{ t("connection.sshUseAgent") }}</SelectItem>');
+ });
+
+ it("exposes the custom agent socket path while keeping the shared auth mapping", () => {
+ expect(managerSource).toContain(`<div v-if="selectedSsh.auth_method === 'agent'" class="grid grid-cols-4 items-center gap-4">`);
+ expect(managerSource).toContain('v-model="selectedSsh.ssh_agent_sock_path"');
+ expect(managerSource).toContain('import { applySshAuthMethod } from "@/lib/connection/sshAuthMethod";');
+ expect(managerSource).toContain("applySshAuthMethod(profile, value);");
+ });
+
+ it("does not keep a second auth-method mapping that could drift from applySshAuthMethod", () => {
+ expect(managerSource).not.toContain('value === "key+password" ? "key+password"');
+ });
+});