mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 14:46:01 +00:00
SYNC: private cloud UX + fixes
This commit is contained in:
committed by
Diflow
parent
f2af38da4c
commit
d668128a34
@@ -4,6 +4,7 @@ const { getSshTunnelProxy } = require('./sshTunnelProxy');
|
||||
const platformInfo = require('../utility/platformInfo');
|
||||
const connections = require('../controllers/connections');
|
||||
const _ = require('lodash');
|
||||
const { getCloudFolderEncryptor } = require('./cloudIntf');
|
||||
|
||||
async function loadConnection(driver, storedConnection, connectionMode) {
|
||||
const { allowShellConnection, allowConnectionFromEnvVariables } = platformInfo;
|
||||
@@ -88,13 +89,31 @@ async function extractConnectionSslParams(connection) {
|
||||
return ssl;
|
||||
}
|
||||
|
||||
async function decryptCloudConnection(connection) {
|
||||
const m = connection?._id?.match(/^cloud\:\/\/(.+)\/(.+)$/);
|
||||
if (!m) {
|
||||
throw new Error('Invalid cloud connection ID format');
|
||||
}
|
||||
|
||||
const folid = m[1];
|
||||
const cntid = m[2];
|
||||
|
||||
const folderEncryptor = await getCloudFolderEncryptor(folid);
|
||||
return decryptConnection(connection, folderEncryptor);
|
||||
}
|
||||
|
||||
async function connectUtility(driver, storedConnection, connectionMode, additionalOptions = null) {
|
||||
const connectionLoaded = await loadConnection(driver, storedConnection, connectionMode);
|
||||
|
||||
const connection = {
|
||||
database: connectionLoaded.defaultDatabase,
|
||||
...decryptConnection(connectionLoaded),
|
||||
};
|
||||
const connection = connectionLoaded?._id?.startsWith('cloud://')
|
||||
? {
|
||||
database: connectionLoaded.defaultDatabase,
|
||||
...(await decryptCloudConnection(connectionLoaded)),
|
||||
}
|
||||
: {
|
||||
database: connectionLoaded.defaultDatabase,
|
||||
...decryptConnection(connectionLoaded),
|
||||
};
|
||||
|
||||
if (!connection.port && driver.defaultPort) {
|
||||
connection.port = driver.defaultPort.toString();
|
||||
|
||||
Reference in New Issue
Block a user