mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 20:46:01 +00:00
dbmodel - allow connection from env variables
This commit is contained in:
@@ -3,9 +3,10 @@ const { decryptConnection } = require('./crypting');
|
||||
const { getSshTunnelProxy } = require('./sshTunnelProxy');
|
||||
const platformInfo = require('../utility/platformInfo');
|
||||
const connections = require('../controllers/connections');
|
||||
const _ = require('lodash');
|
||||
|
||||
async function loadConnection(driver, storedConnection, connectionMode) {
|
||||
const { allowShellConnection } = platformInfo;
|
||||
const { allowShellConnection, allowConnectionFromEnvVariables } = platformInfo;
|
||||
|
||||
if (connectionMode == 'app') {
|
||||
return storedConnection;
|
||||
@@ -33,6 +34,16 @@ async function loadConnection(driver, storedConnection, connectionMode) {
|
||||
}
|
||||
return loadedWithDb;
|
||||
}
|
||||
|
||||
if (allowConnectionFromEnvVariables) {
|
||||
return _.mapValues(storedConnection, (value, key) => {
|
||||
if (_.isString(value) && value.startsWith('$')) {
|
||||
return process.env[value.substring(1)];
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
return storedConnection;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ const platformInfo = {
|
||||
(!processArgs.listenApiChild && !isNpmDist) || !!process.env.SHELL_CONNECTION || !!isElectron() || !!isDbModel,
|
||||
allowShellScripting:
|
||||
(!processArgs.listenApiChild && !isNpmDist) || !!process.env.SHELL_SCRIPTING || !!isElectron() || !!isDbModel,
|
||||
allowConnectionFromEnvVariables: !!isDbModel,
|
||||
defaultKeyfile: path.join(os.homedir(), '.ssh/id_rsa'),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user