mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 11:03:57 +00:00
SYNC: send encryption key to child processes
This commit is contained in:
committed by
Diflow
parent
ef1eff2ecb
commit
e35f9eb75b
@@ -5,12 +5,16 @@ const path = require('path');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { datadir } = require('./directories');
|
const { datadir } = require('./directories');
|
||||||
|
const { encryptionKeyArg } = require('./processArgs');
|
||||||
|
|
||||||
const defaultEncryptionKey = 'mQAUaXhavRGJDxDTXSCg7Ej0xMmGCrx6OKA07DIMBiDcYYkvkaXjTAzPUEHEHEf9';
|
const defaultEncryptionKey = 'mQAUaXhavRGJDxDTXSCg7Ej0xMmGCrx6OKA07DIMBiDcYYkvkaXjTAzPUEHEHEf9';
|
||||||
|
|
||||||
let _encryptionKey = null;
|
let _encryptionKey = null;
|
||||||
|
|
||||||
function loadEncryptionKey() {
|
function loadEncryptionKey() {
|
||||||
|
if (encryptionKeyArg) {
|
||||||
|
return encryptionKeyArg;
|
||||||
|
}
|
||||||
if (_encryptionKey) {
|
if (_encryptionKey) {
|
||||||
return _encryptionKey;
|
return _encryptionKey;
|
||||||
}
|
}
|
||||||
@@ -131,6 +135,11 @@ function pickSafeConnectionInfo(connection) {
|
|||||||
function setEncryptionKey(encryptionKey) {
|
function setEncryptionKey(encryptionKey) {
|
||||||
_encryptionKey = encryptionKey;
|
_encryptionKey = encryptionKey;
|
||||||
_encryptor = null;
|
_encryptor = null;
|
||||||
|
global.ENCRYPTION_KEY = encryptionKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEncryptionKey() {
|
||||||
|
return _encryptionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -142,4 +151,6 @@ module.exports = {
|
|||||||
maskConnection,
|
maskConnection,
|
||||||
pickSafeConnectionInfo,
|
pickSafeConnectionInfo,
|
||||||
loadEncryptionKeyFromExternal,
|
loadEncryptionKeyFromExternal,
|
||||||
|
getEncryptionKey,
|
||||||
|
setEncryptionKey,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const processDisplayName = getNamedArg('--process-display-name');
|
|||||||
const listenApi = process.argv.includes('--listen-api');
|
const listenApi = process.argv.includes('--listen-api');
|
||||||
const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
|
const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
|
||||||
const runE2eTests = process.argv.includes('--run-e2e-tests');
|
const runE2eTests = process.argv.includes('--run-e2e-tests');
|
||||||
|
const encryptionKeyArg = getNamedArg('--encryption-key');
|
||||||
|
|
||||||
function getPassArgs() {
|
function getPassArgs() {
|
||||||
const res = [];
|
const res = [];
|
||||||
@@ -31,6 +32,9 @@ function getPassArgs() {
|
|||||||
if (runE2eTests) {
|
if (runE2eTests) {
|
||||||
res.push('--run-e2e-tests');
|
res.push('--run-e2e-tests');
|
||||||
}
|
}
|
||||||
|
if (global['ENCRYPTION_KEY']) {
|
||||||
|
res.push('--encryption-key', global['ENCRYPTION_KEY']);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,4 +49,5 @@ module.exports = {
|
|||||||
listenApiChild,
|
listenApiChild,
|
||||||
processDisplayName,
|
processDisplayName,
|
||||||
runE2eTests,
|
runE2eTests,
|
||||||
|
encryptionKeyArg,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user