diff --git a/src/backend/database/routes/ssh.ts b/src/backend/database/routes/ssh.ts index c14419b0..9d299aa8 100644 --- a/src/backend/database/routes/ssh.ts +++ b/src/backend/database/routes/ssh.ts @@ -14,7 +14,17 @@ import { hostAccess, userRoles, } from "../db/schema.js"; -import { eq, and, desc, isNotNull, or, isNull, gte, sql, inArray } from "drizzle-orm"; +import { + eq, + and, + desc, + isNotNull, + or, + isNull, + gte, + sql, + inArray, +} from "drizzle-orm"; import type { Request, Response } from "express"; import multer from "multer"; import { sshLogger } from "../../utils/logger.js"; @@ -253,6 +263,7 @@ router.post( socks5Username, socks5Password, socks5ProxyChain, + overrideCredentialUsername, } = hostData; console.log("POST /db/ssh - Received SOCKS5 data:", { @@ -287,6 +298,7 @@ router.post( username, authType: effectiveAuthType, credentialId: credentialId || null, + overrideCredentialUsername: overrideCredentialUsername ? 1 : 0, pin: pin ? 1 : 0, enableTerminal: enableTerminal ? 1 : 0, enableTunnel: enableTunnel ? 1 : 0, @@ -310,7 +322,9 @@ router.post( socks5Port: socks5Port || null, socks5Username: socks5Username || null, socks5Password: socks5Password || null, - socks5ProxyChain: socks5ProxyChain ? JSON.stringify(socks5ProxyChain) : null, + socks5ProxyChain: socks5ProxyChain + ? JSON.stringify(socks5ProxyChain) + : null, }; if (effectiveAuthType === "password") { @@ -501,6 +515,7 @@ router.put( socks5Username, socks5Password, socks5ProxyChain, + overrideCredentialUsername, } = hostData; // Temporary logging to debug notes and expirationDate @@ -533,6 +548,7 @@ router.put( username, authType: effectiveAuthType, credentialId: credentialId || null, + overrideCredentialUsername: overrideCredentialUsername ? 1 : 0, pin: pin ? 1 : 0, enableTerminal: enableTerminal ? 1 : 0, enableTunnel: enableTunnel ? 1 : 0, @@ -556,7 +572,9 @@ router.put( socks5Port: socks5Port || null, socks5Username: socks5Username || null, socks5Password: socks5Password || null, - socks5ProxyChain: socks5ProxyChain ? JSON.stringify(socks5ProxyChain) : null, + socks5ProxyChain: socks5ProxyChain + ? JSON.stringify(socks5ProxyChain) + : null, }; if (effectiveAuthType === "password") { @@ -754,6 +772,8 @@ router.get( credentialId: sshData.credentialId, overrideCredentialUsername: sshData.overrideCredentialUsername, quickActions: sshData.quickActions, + notes: sshData.notes, + expirationDate: sshData.expirationDate, // Shared access info isShared: sql`${hostAccess.id} IS NOT NULL`, @@ -767,12 +787,11 @@ router.get( eq(hostAccess.hostId, sshData.id), or( eq(hostAccess.userId, userId), - roleIds.length > 0 ? inArray(hostAccess.roleId, roleIds) : sql`false`, - ), - or( - isNull(hostAccess.expiresAt), - gte(hostAccess.expiresAt, now), + roleIds.length > 0 + ? inArray(hostAccess.roleId, roleIds) + : sql`false`, ), + or(isNull(hostAccess.expiresAt), gte(hostAccess.expiresAt, now)), ), ) .where( @@ -781,10 +800,7 @@ router.get( and( // Shared to user directly (not expired) eq(hostAccess.userId, userId), - or( - isNull(hostAccess.expiresAt), - gte(hostAccess.expiresAt, now), - ), + or(isNull(hostAccess.expiresAt), gte(hostAccess.expiresAt, now)), ), roleIds.length > 0 ? and( diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json index 6056824f..f4f5d66b 100644 --- a/src/locales/ru/translation.json +++ b/src/locales/ru/translation.json @@ -917,7 +917,7 @@ "noProxyNodes": "Узлы прокси не настроены. Нажмите 'Добавить узел прокси' чтобы добавить.", "proxyNode": "Узел прокси", "proxyType": "Тип прокси", - "advancedAuthSettings": "Расширенные настройки аутентификации" + "advancedAuthSettings": "Расширенные настройки аутентификации", "advancedAuthSettings": "Расширенные настройки аутентификации", "addQuickAction": "Добавить Quick Action", "allHostsInFolderDeleted": "{{count}} хостов успешно удалены из папки \"{{folder}}\"", @@ -1837,4 +1837,4 @@ "close": "Закрыть", "hostManager": "Менеджер хостов" } -} \ No newline at end of file +} diff --git a/src/ui/desktop/apps/host-manager/HostManagerEditor.tsx b/src/ui/desktop/apps/host-manager/HostManagerEditor.tsx index 579827b9..c95f7c19 100644 --- a/src/ui/desktop/apps/host-manager/HostManagerEditor.tsx +++ b/src/ui/desktop/apps/host-manager/HostManagerEditor.tsx @@ -869,15 +869,6 @@ export function HostManagerEditor({ const submitData: Partial = { ...data, }; - - if (proxyMode === "single") { - submitData.socks5ProxyChain = []; - } else if (proxyMode === "chain") { - submitData.socks5Host = ""; - submitData.socks5Port = 1080; - submitData.socks5Username = ""; - submitData.socks5Password = ""; - } if (data.authType !== "credential") { submitData.credentialId = undefined; diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index ee77c452..3bc4ebf9 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -643,7 +643,7 @@ function initializeApiInstances() { // RBAC API (port 30001) rbacApi = createApiInstance(getApiUrl("", 30001), "RBAC"); - + // Docker Management API (port 30007) dockerApi = createApiInstance(getApiUrl("/docker", 30007), "DOCKER"); } @@ -3244,7 +3244,9 @@ export async function updateRole( } } -export async function deleteRole(roleId: number): Promise<{ success: boolean }> { +export async function deleteRole( + roleId: number, +): Promise<{ success: boolean }> { try { const response = await rbacApi.delete(`/rbac/roles/${roleId}`); return response.data; @@ -3254,7 +3256,9 @@ export async function deleteRole(roleId: number): Promise<{ success: boolean }> } // User-Role Management -export async function getUserRoles(userId: string): Promise<{ roles: UserRole[] }> { +export async function getUserRoles( + userId: string, +): Promise<{ roles: UserRole[] }> { try { const response = await rbacApi.get(`/rbac/users/${userId}/roles`); return response.data; @@ -3268,7 +3272,9 @@ export async function assignRoleToUser( roleId: number, ): Promise<{ success: boolean }> { try { - const response = await rbacApi.post(`/rbac/users/${userId}/roles`, { roleId }); + const response = await rbacApi.post(`/rbac/users/${userId}/roles`, { + roleId, + }); return response.data; } catch (error) { throw handleApiError(error, "assign role to user"); @@ -3280,7 +3286,9 @@ export async function removeRoleFromUser( roleId: number, ): Promise<{ success: boolean }> { try { - const response = await rbacApi.delete(`/rbac/users/${userId}/roles/${roleId}`); + const response = await rbacApi.delete( + `/rbac/users/${userId}/roles/${roleId}`, + ); return response.data; } catch (error) { throw handleApiError(error, "remove role from user"); @@ -3299,14 +3307,19 @@ export async function shareHost( }, ): Promise<{ success: boolean }> { try { - const response = await rbacApi.post(`/rbac/host/${hostId}/share`, shareData); + const response = await rbacApi.post( + `/rbac/host/${hostId}/share`, + shareData, + ); return response.data; } catch (error) { throw handleApiError(error, "share host"); } } -export async function getHostAccess(hostId: number): Promise<{ accessList: AccessRecord[] }> { +export async function getHostAccess( + hostId: number, +): Promise<{ accessList: AccessRecord[] }> { try { const response = await rbacApi.get(`/rbac/host/${hostId}/access`); return response.data; @@ -3320,11 +3333,15 @@ export async function revokeHostAccess( accessId: number, ): Promise<{ success: boolean }> { try { - const response = await rbacApi.delete(`/rbac/host/${hostId}/access/${accessId}`); + const response = await rbacApi.delete( + `/rbac/host/${hostId}/access/${accessId}`, + ); return response.data; } catch (error) { throw handleApiError(error, "revoke host access"); - + } +} + // ============================================================================ // DOCKER MANAGEMENT API // ============================================================================