mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 14:16:01 +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 { datadir } = require('./directories');
|
||||
const { encryptionKeyArg } = require('./processArgs');
|
||||
|
||||
const defaultEncryptionKey = 'mQAUaXhavRGJDxDTXSCg7Ej0xMmGCrx6OKA07DIMBiDcYYkvkaXjTAzPUEHEHEf9';
|
||||
|
||||
let _encryptionKey = null;
|
||||
|
||||
function loadEncryptionKey() {
|
||||
if (encryptionKeyArg) {
|
||||
return encryptionKeyArg;
|
||||
}
|
||||
if (_encryptionKey) {
|
||||
return _encryptionKey;
|
||||
}
|
||||
@@ -131,6 +135,11 @@ function pickSafeConnectionInfo(connection) {
|
||||
function setEncryptionKey(encryptionKey) {
|
||||
_encryptionKey = encryptionKey;
|
||||
_encryptor = null;
|
||||
global.ENCRYPTION_KEY = encryptionKey;
|
||||
}
|
||||
|
||||
function getEncryptionKey() {
|
||||
return _encryptionKey;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@@ -142,4 +151,6 @@ module.exports = {
|
||||
maskConnection,
|
||||
pickSafeConnectionInfo,
|
||||
loadEncryptionKeyFromExternal,
|
||||
getEncryptionKey,
|
||||
setEncryptionKey,
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ const processDisplayName = getNamedArg('--process-display-name');
|
||||
const listenApi = process.argv.includes('--listen-api');
|
||||
const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
|
||||
const runE2eTests = process.argv.includes('--run-e2e-tests');
|
||||
const encryptionKeyArg = getNamedArg('--encryption-key');
|
||||
|
||||
function getPassArgs() {
|
||||
const res = [];
|
||||
@@ -31,6 +32,9 @@ function getPassArgs() {
|
||||
if (runE2eTests) {
|
||||
res.push('--run-e2e-tests');
|
||||
}
|
||||
if (global['ENCRYPTION_KEY']) {
|
||||
res.push('--encryption-key', global['ENCRYPTION_KEY']);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -45,4 +49,5 @@ module.exports = {
|
||||
listenApiChild,
|
||||
processDisplayName,
|
||||
runE2eTests,
|
||||
encryptionKeyArg,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user