CLT with INI and SSO setup

CLT with INI and SSO setup
This commit is contained in:
Shahana Farooqui 2020-01-17 13:45:01 -05:00
parent 17ce7ca5df
commit 3a39dc7b86
6 changed files with 1859 additions and 718 deletions

1
.gitignore vendored
View file

@ -45,3 +45,4 @@ RTL-Multi-Node-Conf-1.json
/backup/* /backup/*
cookies cookies
sample-RTL-SSO.conf sample-RTL-SSO.conf
.env

View file

@ -92,21 +92,21 @@ connect.normalizePort = val => {
connect.setMacaroonPath = (clArgs, config) => { connect.setMacaroonPath = (clArgs, config) => {
common.nodes[0] = {}; common.nodes[0] = {};
common.nodes[0].index = 1; common.nodes[0].index = 1;
if(undefined !== clArgs.lndir) { if(clArgs.lndir) {
common.nodes[0].macaroon_path = clArgs.lndir; common.nodes[0].macaroon_path = clArgs.lndir;
} else if (undefined !== process.env.MACAROON_PATH) { } else if (process.env.MACAROON_PATH) {
common.nodes[0].macaroon_path = process.env.MACAROON_PATH; common.nodes[0].macaroon_path = process.env.MACAROON_PATH;
} else { } else {
if(undefined !== config.Authentication.macroonPath && config.Authentication.macroonPath !== '') { if(config.Authentication.macroonPath && config.Authentication.macroonPath !== '') {
common.nodes[0].macaroon_path = config.Authentication.macroonPath; common.nodes[0].macaroon_path = config.Authentication.macroonPath;
} else if(undefined !== config.Authentication.macaroonPath && config.Authentication.macaroonPath !== '') { } else if(config.Authentication.macaroonPath && config.Authentication.macaroonPath !== '') {
common.nodes[0].macaroon_path = config.Authentication.macaroonPath; common.nodes[0].macaroon_path = config.Authentication.macaroonPath;
} }
} }
} }
connect.convertCustomToHash = (nodeSetupType) => { connect.convertCustomToHash = (nodeSetupType) => {
common.rtl_conf_file_path = (undefined !== process.env.RTL_CONFIG_PATH) ? process.env.RTL_CONFIG_PATH.substring(0, process.env.RTL_CONFIG_PATH.length - 9) : path.normalize(__dirname); common.rtl_conf_file_path = (process.env.RTL_CONFIG_PATH) ? process.env.RTL_CONFIG_PATH.substring(0, process.env.RTL_CONFIG_PATH.length - 9) : path.normalize(__dirname);
if(nodeSetupType === 'SINGLE') { if(nodeSetupType === 'SINGLE') {
try { try {
RTLConfFile = common.rtl_conf_file_path + '/RTL.conf'; RTLConfFile = common.rtl_conf_file_path + '/RTL.conf';
@ -117,7 +117,7 @@ connect.convertCustomToHash = (nodeSetupType) => {
delete config.Authentication; delete config.Authentication;
fs.writeFileSync(RTLConfFile, ini.stringify(config)); fs.writeFileSync(RTLConfFile, ini.stringify(config));
fs.appendFileSync(RTLConfFile, ini.stringify(authTemp, { section: 'Authentication' })); fs.appendFileSync(RTLConfFile, ini.stringify(authTemp, { section: 'Authentication' }));
console.log('Please note that RTL has encrypted the plaintext password into its corresponding hash.'); console.log('Please note that RTL has hashed the plaintext password into its corresponding hash.');
return authTemp.rtlPassHashed; return authTemp.rtlPassHashed;
} catch (err) { } catch (err) {
errMsg = errMsg + '\nrtlPass hash conversion failed!'; errMsg = errMsg + '\nrtlPass hash conversion failed!';
@ -139,33 +139,17 @@ connect.convertCustomToHash = (nodeSetupType) => {
} }
connect.validateSingleNodeConfig = (config) => { connect.validateSingleNodeConfig = (config) => {
if(common.nodes[0].macaroon_path === '' || undefined === common.nodes[0].macaroon_path) { connect.setSSOParams(config);
errMsg = 'Please set macaroon path through environment or RTL.conf!';
}
if(undefined !== process.env.LND_SERVER_URL) { if(process.env.LN_IMPLEMENTATION) {
common.nodes[0].ln_server_url = process.env.LND_SERVER_URL; common.nodes[0].ln_implementation = process.env.LN_IMPLEMENTATION;
} else if(undefined !== process.env.LN_SERVER_URL) { } else if (config.Settings.lnImplementation && config.Settings.lnImplementation !== '') {
common.nodes[0].ln_server_url = process.env.LN_SERVER_URL; common.nodes[0].ln_implementation = config.Settings.lnImplementation;
} else { } else {
if( common.nodes[0].ln_implementation = 'LND';
(config.Authentication.lndServerUrl === '' || undefined === config.Authentication.lndServerUrl)
&& (config.Settings.lndServerUrl === '' || undefined === config.Settings.lndServerUrl)
&& (config.Settings.lnServerUrl === '' || undefined === config.Settings.lnServerUrl)
) {
errMsg = errMsg + '\nPlease set Server URL through environment or RTL.conf!';
} else {
if (config.Settings.lndServerUrl !== '' && undefined !== config.Settings.lndServerUrl) {
common.nodes[0].ln_server_url = config.Settings.lndServerUrl;
} else if (config.Authentication.lndServerUrl !== '' && undefined !== config.Authentication.lndServerUrl) {
common.nodes[0].ln_server_url = config.Authentication.lndServerUrl;
} else if (config.Settings.lnServerUrl !== '' && undefined !== config.Settings.lnServerUrl) {
common.nodes[0].ln_server_url = config.Settings.lnServerUrl;
} }
} if(!+common.rtl_sso) {
} if(process.env.NODE_AUTH_TYPE) {
if(undefined !== process.env.NODE_AUTH_TYPE) {
common.node_auth_type = process.env.NODE_AUTH_TYPE; common.node_auth_type = process.env.NODE_AUTH_TYPE;
} else { } else {
if(config.Authentication.nodeAuthType === '' || undefined === config.Authentication.nodeAuthType) { if(config.Authentication.nodeAuthType === '' || undefined === config.Authentication.nodeAuthType) {
@ -175,14 +159,26 @@ connect.validateSingleNodeConfig = (config) => {
} }
} }
if(undefined !== process.env.LND_CONFIG_PATH) { if (process.env.RTL_PASS) {
common.rtl_pass = hash.update(process.env.RTL_PASS).digest('hex');
} else if (config.Authentication.rtlPassHashed !== '' && config.Authentication.rtlPassHashed) {
common.rtl_pass = config.Authentication.rtlPassHashed;
} else if (config.Authentication.rtlPass !== '' && config.Authentication.rtlPass) {
common.rtl_pass = connect.convertCustomToHash('SINGLE');
}
if (upperCase(common.node_auth_type) === 'CUSTOM' && (common.rtl_pass === '' || undefined === common.rtl_pass)) {
errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password through environment or RTL.conf';
}
if(process.env.LND_CONFIG_PATH) {
common.nodes[0].config_path = process.env.LND_CONFIG_PATH; common.nodes[0].config_path = process.env.LND_CONFIG_PATH;
} else if (undefined !== process.env.CONFIG_PATH) { } else if (process.env.CONFIG_PATH) {
common.nodes[0].config_path = process.env.CONFIG_PATH; common.nodes[0].config_path = process.env.CONFIG_PATH;
} else { } else {
if(config.Authentication.lndConfigPath !== '' && undefined !== config.Authentication.lndConfigPath) { if(config.Authentication.lndConfigPath !== '' && config.Authentication.lndConfigPath) {
common.nodes[0].config_path = config.Authentication.lndConfigPath; common.nodes[0].config_path = config.Authentication.lndConfigPath;
} else if(config.Authentication.ConfigPath !== '' && undefined !== config.Authentication.ConfigPath) { } else if(config.Authentication.ConfigPath !== '' && config.Authentication.ConfigPath) {
common.nodes[0].config_path = config.Authentication.ConfigPath; common.nodes[0].config_path = config.Authentication.ConfigPath;
} else { } else {
if(upperCase(common.node_auth_type) === 'DEFAULT') { if(upperCase(common.node_auth_type) === 'DEFAULT') {
@ -191,20 +187,49 @@ connect.validateSingleNodeConfig = (config) => {
} }
} }
if(undefined !== process.env.BITCOIND_CONFIG_PATH) { }
if(common.nodes[0].macaroon_path === '' || undefined === common.nodes[0].macaroon_path) {
errMsg = 'Please set macaroon path through environment or RTL.conf!';
}
if(process.env.LND_SERVER_URL) {
common.nodes[0].ln_server_url = process.env.LND_SERVER_URL;
} else if(process.env.LN_SERVER_URL) {
common.nodes[0].ln_server_url = process.env.LN_SERVER_URL;
} else {
if(
(config.Authentication.lndServerUrl === '' || undefined === config.Authentication.lndServerUrl)
&& (config.Settings.lndServerUrl === '' || undefined === config.Settings.lndServerUrl)
&& (config.Settings.lnServerUrl === '' || undefined === config.Settings.lnServerUrl)
) {
errMsg = errMsg + '\nPlease set Server URL through environment or RTL.conf!';
} else {
if (config.Settings.lndServerUrl !== '' && config.Settings.lndServerUrl) {
common.nodes[0].ln_server_url = config.Settings.lndServerUrl;
} else if (config.Authentication.lndServerUrl !== '' && config.Authentication.lndServerUrl) {
common.nodes[0].ln_server_url = config.Authentication.lndServerUrl;
} else if (config.Settings.lnServerUrl !== '' && config.Settings.lnServerUrl) {
common.nodes[0].ln_server_url = config.Settings.lnServerUrl;
}
}
}
if(process.env.BITCOIND_CONFIG_PATH) {
common.nodes[0].bitcoind_config_path = process.env.BITCOIND_CONFIG_PATH; common.nodes[0].bitcoind_config_path = process.env.BITCOIND_CONFIG_PATH;
} else { } else {
if(config.Settings.bitcoindConfigPath !== '' && undefined !== config.Settings.bitcoindConfigPath) { if(config.Settings.bitcoindConfigPath !== '' && config.Settings.bitcoindConfigPath) {
common.nodes[0].bitcoind_config_path = config.Settings.bitcoindConfigPath; common.nodes[0].bitcoind_config_path = config.Settings.bitcoindConfigPath;
} else if(config.Authentication.bitcoindConfigPath !== '' && undefined !== config.Authentication.bitcoindConfigPath) { } else if(config.Authentication.bitcoindConfigPath !== '' && config.Authentication.bitcoindConfigPath) {
common.nodes[0].bitcoind_config_path = config.Authentication.bitcoindConfigPath; common.nodes[0].bitcoind_config_path = config.Authentication.bitcoindConfigPath;
} }
} }
if(undefined !== process.env.CHANNEL_BACKUP_PATH) { if(common.ln_implementation === 'LND') {
if(process.env.CHANNEL_BACKUP_PATH) {
common.nodes[0].channel_backup_path = process.env.CHANNEL_BACKUP_PATH; common.nodes[0].channel_backup_path = process.env.CHANNEL_BACKUP_PATH;
} else { } else {
if(config.Settings.channelBackupPath !== '' && undefined !== config.Settings.channelBackupPath) { if(config.Settings.channelBackupPath !== '' && config.Settings.channelBackupPath) {
common.nodes[0].channel_backup_path = config.Settings.channelBackupPath; common.nodes[0].channel_backup_path = config.Settings.channelBackupPath;
} else { } else {
common.nodes[0].channel_backup_path = common.rtl_conf_file_path + common.path_separator + 'backup'; common.nodes[0].channel_backup_path = common.rtl_conf_file_path + common.path_separator + 'backup';
@ -224,34 +249,11 @@ connect.validateSingleNodeConfig = (config) => {
console.error('Something went wrong while creating backup file: \n' + err); console.error('Something went wrong while creating backup file: \n' + err);
} }
} }
if(undefined !== process.env.LN_IMPLEMENTATION) {
common.ln_implementation = process.env.LN_IMPLEMENTATION;
} else if (config.lnImplementation && config.lnImplementation !== '') {
common.ln_implementation = config.lnImplementation;
} else {
common.ln_implementation = 'LND';
} }
if(!+config.SSO.rtlSSO) { if (config.Settings.enableLogging) {
if (undefined !== process.env.RTL_PASS) {
common.rtl_pass = hash.update(process.env.RTL_PASS).digest('hex');
} else if (config.Authentication.rtlPassHashed !== '' && undefined !== config.Authentication.rtlPassHashed) {
common.rtl_pass = config.Authentication.rtlPassHashed;
} else if (config.Authentication.rtlPass !== '' && undefined !== config.Authentication.rtlPass) {
common.rtl_pass = connect.convertCustomToHash('SINGLE');
}
}
if (upperCase(common.node_auth_type) === 'CUSTOM' && (common.rtl_pass === '' || undefined === common.rtl_pass)) {
errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password through environment or RTL.conf';
}
if (undefined !== process.env.ENABLE_LOGGING) {
common.nodes[0].enable_logging = process.env.ENABLE_LOGGING;
} else if (undefined !== config.Settings.enableLogging) {
common.nodes[0].enable_logging = config.Settings.enableLogging; common.nodes[0].enable_logging = config.Settings.enableLogging;
} else if (undefined !== config.Authentication.enableLogging) { } else if (config.Authentication.enableLogging) {
common.nodes[0].enable_logging = config.Authentication.enableLogging; common.nodes[0].enable_logging = config.Authentication.enableLogging;
} }
if (common.nodes[0].enable_logging) { if (common.nodes[0].enable_logging) {
@ -272,27 +274,22 @@ connect.validateSingleNodeConfig = (config) => {
} }
} }
if (process.env.FIAT_CONVERSION) { if (config.Settings.fiatConversion) {
common.nodes[0].fiat_conversion = process.env.FIAT_CONVERSION;
} else if (undefined !== config.Settings.fiatConversion) {
common.nodes[0].fiat_conversion = config.Settings.fiatConversion; common.nodes[0].fiat_conversion = config.Settings.fiatConversion;
} else { } else {
common.nodes[0].fiat_conversion = false; common.nodes[0].fiat_conversion = false;
} }
if (process.env.FIAT_CONVERSION && process.env.CURRENCY_UNIT) { if (config.Settings.fiatConversion && config.Settings.currencyUnit) {
common.nodes[0].currency_unit = process.env.CURRENCY_UNIT;
} else if (config.Settings.fiatConversion && config.Settings.currencyUnit) {
common.nodes[0].currency_unit = config.Settings.currencyUnit; common.nodes[0].currency_unit = config.Settings.currencyUnit;
} }
if (undefined !== process.env.PORT) { if (process.env.PORT) {
common.port = connect.normalizePort(process.env.PORT); common.port = connect.normalizePort(process.env.PORT);
} else if (undefined !== config.Settings.port) { } else if (config.Settings.port) {
common.port = connect.normalizePort(config.Settings.port); common.port = connect.normalizePort(config.Settings.port);
} }
connect.setSSOParams(config);
if (errMsg !== '') { if (errMsg !== '') {
throw new Error(errMsg); throw new Error(errMsg);
} }
@ -302,17 +299,17 @@ connect.validateSingleNodeConfig = (config) => {
connect.validateMultiNodeConfig = (config) => { connect.validateMultiNodeConfig = (config) => {
if(!+config.SSO.rtlSSO) { if(!+config.SSO.rtlSSO) {
common.node_auth_type = 'CUSTOM'; common.node_auth_type = 'CUSTOM';
if (undefined !== process.env.RTL_PASS) { if (process.env.RTL_PASS) {
common.rtl_pass = hash.update(process.env.RTL_PASS).digest('hex'); common.rtl_pass = hash.update(process.env.RTL_PASS).digest('hex');
} else if (config.multiPassHashed !== '' && undefined !== config.multiPassHashed) { } else if (config.multiPassHashed !== '' && config.multiPassHashed) {
common.rtl_pass = config.multiPassHashed; common.rtl_pass = config.multiPassHashed;
} else if (config.multiPass !== '' && undefined !== config.multiPass) { } else if (config.multiPass !== '' && config.multiPass) {
common.rtl_pass = connect.convertCustomToHash('MULTI'); common.rtl_pass = connect.convertCustomToHash('MULTI');
} else { } else {
errMsg = errMsg + '\nMulti Node Authentication can be set with multiPass only. Please set MultiPass in RTL-Multi-Node-Conf.json'; errMsg = errMsg + '\nMulti Node Authentication can be set with multiPass only. Please set MultiPass in RTL-Multi-Node-Conf.json';
} }
} }
common.port = (undefined !== config.port) ? connect.normalizePort(config.port) : 3000; common.port = (config.port) ? connect.normalizePort(config.port) : 3000;
if (config.nodes && config.nodes.length > 0) { if (config.nodes && config.nodes.length > 0) {
config.nodes.forEach((node, idx) => { config.nodes.forEach((node, idx) => {
common.nodes[idx] = {}; common.nodes[idx] = {};
@ -339,16 +336,16 @@ connect.validateMultiNodeConfig = (config) => {
common.nodes[idx].currency_unit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD'; common.nodes[idx].currency_unit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
} }
if (undefined !== node.Authentication && undefined !== node.Authentication.lndConfigPath) { if (node.Authentication && node.Authentication.lndConfigPath) {
common.nodes[idx].config_path = node.Authentication.lndConfigPath; common.nodes[idx].config_path = node.Authentication.lndConfigPath;
} else if (undefined !== node.Authentication && undefined !== node.Authentication.configPath) { } else if (node.Authentication && node.Authentication.configPath) {
common.nodes[idx].config_path = node.Authentication.configPath; common.nodes[idx].config_path = node.Authentication.configPath;
} else { } else {
common.nodes[idx].config_path = ''; common.nodes[idx].config_path = '';
} }
common.nodes[idx].bitcoind_config_path = (undefined !== node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : ''; common.nodes[idx].bitcoind_config_path = (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
common.nodes[idx].enable_logging = (undefined !== node.Settings.enableLogging) ? node.Settings.enableLogging : false; common.nodes[idx].enable_logging = (node.Settings.enableLogging) ? node.Settings.enableLogging : false;
common.nodes[idx].channel_backup_path = (undefined !== node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.rtl_conf_file_path + common.path_separator + 'backup' + common.path_separator + 'node-' + node.index; common.nodes[idx].channel_backup_path = (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.rtl_conf_file_path + common.path_separator + 'backup' + common.path_separator + 'node-' + node.index;
try { try {
connect.createDirectory(common.nodes[idx].channel_backup_path); connect.createDirectory(common.nodes[idx].channel_backup_path);
let exists = fs.existsSync(common.nodes[idx].channel_backup_path + common.path_separator + 'channel-all.bak'); let exists = fs.existsSync(common.nodes[idx].channel_backup_path + common.path_separator + 'channel-all.bak');
@ -389,22 +386,22 @@ connect.validateMultiNodeConfig = (config) => {
} }
connect.setSSOParams = (config) => { connect.setSSOParams = (config) => {
if (undefined !== process.env.RTL_SSO) { if (process.env.RTL_SSO) {
common.rtl_sso = process.env.RTL_SSO; common.rtl_sso = process.env.RTL_SSO;
} else if (undefined !== config.SSO && undefined !== config.SSO.rtlSSO) { } else if (config.SSO && config.SSO.rtlSSO) {
common.rtl_sso = config.SSO.rtlSSO; common.rtl_sso = config.SSO.rtlSSO;
} }
if (+common.rtl_sso) { if (+common.rtl_sso) {
if (undefined !== process.env.LOGOUT_REDIRECT_LINK) { if (process.env.LOGOUT_REDIRECT_LINK) {
common.logout_redirect_link = process.env.LOGOUT_REDIRECT_LINK; common.logout_redirect_link = process.env.LOGOUT_REDIRECT_LINK;
} else if (undefined !== config.SSO && undefined !== config.SSO.logoutRedirectLink) { } else if (config.SSO && config.SSO.logoutRedirectLink) {
common.logout_redirect_link = config.SSO.logoutRedirectLink; common.logout_redirect_link = config.SSO.logoutRedirectLink;
} }
if (undefined !== process.env.RTL_COOKIE_PATH) { if (process.env.RTL_COOKIE_PATH) {
common.rtl_cookie_path = process.env.RTL_COOKIE_PATH; common.rtl_cookie_path = process.env.RTL_COOKIE_PATH;
} else if (undefined !== config.SSO && undefined !== config.SSO.rtlCookiePath) { } else if (config.SSO && config.SSO.rtlCookiePath) {
common.rtl_cookie_path = config.SSO.rtlCookiePath; common.rtl_cookie_path = config.SSO.rtlCookiePath;
} else { } else {
common.rtl_cookie_path = common.rtl_conf_file_path + '/cookies/auth.cookie'; common.rtl_cookie_path = common.rtl_conf_file_path + '/cookies/auth.cookie';
@ -476,28 +473,26 @@ connect.logEnvVariables = () => {
if (common.multi_node_setup && common.nodes && common.nodes.length > 0) { if (common.multi_node_setup && common.nodes && common.nodes.length > 0) {
common.nodes.forEach((node, idx) => { common.nodes.forEach((node, idx) => {
if (!node.enable_logging) { return; } if (!node.enable_logging) { return; }
logger.info({fileName: 'Config Setup Variable', msg: 'DEFAULT_NODE_INDEX: ' + common.selectedNode.index}); logger.info({fileName: 'Config Setup Variable', msg: 'DEFAULT NODE INDEX: ' + common.selectedNode.index});
logger.info({fileName: 'Config Setup Variable', msg: 'NODE_SETUP: MULTI', node}); logger.info({fileName: 'Config Setup Variable', msg: 'NODE_SETUP: MULTI', node});
logger.info({fileName: 'Config Setup Variable', msg: 'RTL_SSO: ' + common.rtl_sso, node}); logger.info({fileName: 'Config Setup Variable', msg: 'SSO: ' + common.rtl_sso, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LOGOUT_REDIRECT_LINK: ' + common.logout_redirect_link + '\r\n', node}); logger.info({fileName: 'Config Setup Variable', msg: 'LOGOUT REDIRECT LINK: ' + common.logout_redirect_link + '\r\n', node});
logger.info({fileName: 'Config Setup Variable', msg: 'INDEX: ' + node.index, node}); logger.info({fileName: 'Config Setup Variable', msg: 'INDEX: ' + node.index, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN NODE: ' + node.ln_node, node}); logger.info({fileName: 'Config Setup Variable', msg: 'LN NODE: ' + node.ln_node, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + node.ln_implementation, node}); logger.info({fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + node.ln_implementation, node});
logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port, node}); logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port, node});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT_CONVERSION: ' + node.fiatConversion, node}); logger.info({fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + node.fiatConversion, node});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + node.currency_unit, node}); logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + node.currency_unit, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LND_SERVER_URL: ' + node.ln_server_url, node}); logger.info({fileName: 'Config Setup Variable', msg: 'LND SERVER URL: ' + node.ln_server_url, node});
}); });
} else { } else {
if (!common.nodes[0].enable_logging) { return; } if (!common.nodes[0].enable_logging) { return; }
logger.info({fileName: 'Config Setup Variable', msg: 'NODE_SETUP: SINGLE'}); logger.info({fileName: 'Config Setup Variable', msg: 'NODE_SETUP: SINGLE'});
logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port}); logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + common.nodes[0].currency_unit}); logger.info({fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + common.nodes[0].ln_implementation});
logger.info({fileName: 'Config Setup Variable', msg: 'LND_SERVER_URL: ' + common.nodes[0].ln_server_url}); logger.info({fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + common.nodes[0].ln_server_url});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT_CONVERSION: ' + common.nodes[0].fiat_conversion}); logger.info({fileName: 'Config Setup Variable', msg: 'SSO: ' + common.rtl_sso});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + common.nodes[0].currency_unit}); logger.info({fileName: 'Config Setup Variable', msg: 'LOGOUT REDIRECT LINK: ' + common.logout_redirect_link});
logger.info({fileName: 'Config Setup Variable', msg: 'RTL_SSO: ' + common.rtl_sso});
logger.info({fileName: 'Config Setup Variable', msg: 'LOGOUT_REDIRECT_LINK: ' + common.logout_redirect_link});
} }
} }
@ -570,19 +565,15 @@ connect.setMultiNodeConfiguration = (multiNodeFilePath) => {
} }
connect.setSelectedNode = (config) => { connect.setSelectedNode = (config) => {
if(undefined !== process.env.DEFAULT_NODE_INDEX) { if(config.defaultNodeIndex) {
common.selectedNode = common.findNode(process.env.DEFAULT_NODE_INDEX);
} else {
if(undefined !== config.defaultNodeIndex) {
common.selectedNode = common.findNode(config.defaultNodeIndex); common.selectedNode = common.findNode(config.defaultNodeIndex);
} else { } else {
common.selectedNode = common.findNode(common.nodes[0].index); common.selectedNode = common.findNode(common.nodes[0].index);
} }
}
} }
connect.setServerConfiguration = () => { connect.setServerConfiguration = () => {
common.rtl_conf_file_path = (undefined !== process.env.RTL_CONFIG_PATH) ? process.env.RTL_CONFIG_PATH.substring(0, process.env.RTL_CONFIG_PATH.length - 9) : path.normalize(__dirname); common.rtl_conf_file_path = (process.env.RTL_CONFIG_PATH) ? process.env.RTL_CONFIG_PATH.substring(0, process.env.RTL_CONFIG_PATH.length - 9) : path.normalize(__dirname);
singleNodeConfFile = common.rtl_conf_file_path + '/RTL.conf'; singleNodeConfFile = common.rtl_conf_file_path + '/RTL.conf';
multiNodeConfFile = common.rtl_conf_file_path + '/RTL-Multi-Node-Conf.json'; multiNodeConfFile = common.rtl_conf_file_path + '/RTL-Multi-Node-Conf.json';
const singleNodeExists = fs.existsSync(singleNodeConfFile); const singleNodeExists = fs.existsSync(singleNodeConfFile);

View file

@ -32,19 +32,20 @@ exports.getRTLConfig = (req, res, next) => {
configPath: common.nodes[0].config_path, configPath: common.nodes[0].config_path,
bitcoindConfigPath: common.nodes[0].bitcoind_config_path bitcoindConfigPath: common.nodes[0].bitcoind_config_path
}; };
jsonConfig.Settings.channelBackupPath = (undefined !== jsonConfig.Settings.channelBackupPath) ? jsonConfig.Settings.channelBackupPath : common.nodes[0].channel_backup_path; jsonConfig.Settings.lnImplementation = (jsonConfig.Settings.lnImplementation) ? jsonConfig.Settings.lnImplementation : common.nodes[0].ln_implementation;
jsonConfig.Settings.flgSidenavOpened = (undefined !== jsonConfig.Settings.flgSidenavOpened) ? jsonConfig.Settings.flgSidenavOpened : true; jsonConfig.Settings.channelBackupPath = (jsonConfig.Settings.channelBackupPath) ? jsonConfig.Settings.channelBackupPath : common.nodes[0].channel_backup_path;
jsonConfig.Settings.flgSidenavPinned = (undefined !== jsonConfig.Settings.flgSidenavPinned) ? jsonConfig.Settings.flgSidenavPinned : true; jsonConfig.Settings.flgSidenavOpened = (jsonConfig.Settings.flgSidenavOpened) ? jsonConfig.Settings.flgSidenavOpened : true;
jsonConfig.Settings.menu = (undefined !== jsonConfig.Settings.menu) ? jsonConfig.Settings.menu : 'VERTICAL'; jsonConfig.Settings.flgSidenavPinned = (jsonConfig.Settings.flgSidenavPinned) ? jsonConfig.Settings.flgSidenavPinned : true;
jsonConfig.Settings.menuType = (undefined !== jsonConfig.Settings.menuType) ? jsonConfig.Settings.menuType : 'REGULAR'; jsonConfig.Settings.menu = (jsonConfig.Settings.menu) ? jsonConfig.Settings.menu : 'VERTICAL';
jsonConfig.Settings.fontSize = (undefined !== jsonConfig.Settings.fontSize) ? jsonConfig.Settings.fontSize : 'MEDIUM'; jsonConfig.Settings.menuType = (jsonConfig.Settings.menuType) ? jsonConfig.Settings.menuType : 'REGULAR';
jsonConfig.Settings.themeMode = (undefined !== jsonConfig.Settings.themeMode) ? jsonConfig.Settings.themeMode : 'DAY'; jsonConfig.Settings.fontSize = (jsonConfig.Settings.fontSize) ? jsonConfig.Settings.fontSize : 'MEDIUM';
jsonConfig.Settings.themeColor = (undefined !== jsonConfig.Settings.themeColor) ? jsonConfig.Settings.themeColor : 'PURPLE'; jsonConfig.Settings.themeMode = (jsonConfig.Settings.themeMode) ? jsonConfig.Settings.themeMode : 'DAY';
jsonConfig.Settings.satsToBTC = (undefined !== jsonConfig.Settings.satsToBTC) ? jsonConfig.Settings.satsToBTC : false; jsonConfig.Settings.themeColor = (jsonConfig.Settings.themeColor) ? jsonConfig.Settings.themeColor : 'PURPLE';
jsonConfig.Settings.satsToBTC = (jsonConfig.Settings.satsToBTC) ? jsonConfig.Settings.satsToBTC : false;
res.status(200).json({ defaultNodeIndex: 0, selectedNodeIndex: common.selectedNode.index, sso: sso, nodes: [{ res.status(200).json({ defaultNodeIndex: 0, selectedNodeIndex: common.selectedNode.index, sso: sso, nodes: [{
index: common.nodes[0].index, index: common.nodes[0].index,
lnNode: 'SingleNode', lnNode: 'SingleNode',
lnImplementation: '', lnImplementation: jsonConfig.Settings.lnImplementation,
settings: jsonConfig.Settings, settings: jsonConfig.Settings,
authentication: authentication}] }); authentication: authentication}] });
} }
@ -82,15 +83,15 @@ exports.getRTLConfig = (req, res, next) => {
if(node.Settings.bitcoindConfigPath) { if(node.Settings.bitcoindConfigPath) {
authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath; authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath;
} }
node.Settings.channelBackupPath = (undefined !== node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.nodes[i].channel_backup_path; node.Settings.channelBackupPath = (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.nodes[i].channel_backup_path;
node.Settings.flgSidenavOpened = (undefined !== node.Settings.flgSidenavOpened) ? node.Settings.flgSidenavOpened : true; node.Settings.flgSidenavOpened = (node.Settings.flgSidenavOpened) ? node.Settings.flgSidenavOpened : true;
node.Settings.flgSidenavPinned = (undefined !== node.Settings.flgSidenavPinned) ? node.Settings.flgSidenavPinned : true; node.Settings.flgSidenavPinned = (node.Settings.flgSidenavPinned) ? node.Settings.flgSidenavPinned : true;
node.Settings.menu = (undefined !== node.Settings.menu) ? node.Settings.menu : 'VERTICAL'; node.Settings.menu = (node.Settings.menu) ? node.Settings.menu : 'VERTICAL';
node.Settings.menuType = (undefined !== node.Settings.menuType) ? node.Settings.menuType : 'REGULAR'; node.Settings.menuType = (node.Settings.menuType) ? node.Settings.menuType : 'REGULAR';
node.Settings.fontSize = (undefined !== node.Settings.fontSize) ? node.Settings.fontSize : 'MEDIUM'; node.Settings.fontSize = (node.Settings.fontSize) ? node.Settings.fontSize : 'MEDIUM';
node.Settings.themeMode = (undefined !== node.Settings.themeMode) ? node.Settings.themeMode : 'DAY'; node.Settings.themeMode = (node.Settings.themeMode) ? node.Settings.themeMode : 'DAY';
node.Settings.themeColor = (undefined !== node.Settings.themeColor) ? node.Settings.themeColor : 'PURPLE'; node.Settings.themeColor = (node.Settings.themeColor) ? node.Settings.themeColor : 'PURPLE';
node.Settings.satsToBTC = (undefined !== node.Settings.satsToBTC) ? node.Settings.satsToBTC : false; node.Settings.satsToBTC = (node.Settings.satsToBTC) ? node.Settings.satsToBTC : false;
nodesArr.push({ nodesArr.push({
index: node.index, index: node.index,
lnNode: node.lnNode, lnNode: node.lnNode,
@ -224,19 +225,19 @@ exports.getConfig = (req, res, next) => {
}); });
} else { } else {
const jsonConfig = (JSONFormat) ? JSON.parse(data) : ini.parse(data); const jsonConfig = (JSONFormat) ? JSON.parse(data) : ini.parse(data);
if (undefined !== jsonConfig.Authentication && undefined !== jsonConfig.Authentication.rtlPass) { if (jsonConfig.Authentication && jsonConfig.Authentication.rtlPass) {
jsonConfig.Authentication.rtlPass = jsonConfig.Authentication.rtlPass.replace(/./g, '*'); jsonConfig.Authentication.rtlPass = jsonConfig.Authentication.rtlPass.replace(/./g, '*');
} }
if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) { if (jsonConfig.Bitcoind && jsonConfig.Bitcoind['bitcoind.rpcpass']) {
jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*'); jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*');
} }
if (undefined !== jsonConfig['bitcoind.rpcpass']) { if (jsonConfig['bitcoind.rpcpass']) {
jsonConfig['bitcoind.rpcpass'] = jsonConfig['bitcoind.rpcpass'].replace(/./g, '*'); jsonConfig['bitcoind.rpcpass'] = jsonConfig['bitcoind.rpcpass'].replace(/./g, '*');
} }
if (undefined !== jsonConfig['rpcpassword']) { if (jsonConfig['rpcpassword']) {
jsonConfig['rpcpassword'] = jsonConfig['rpcpassword'].replace(/./g, '*'); jsonConfig['rpcpassword'] = jsonConfig['rpcpassword'].replace(/./g, '*');
} }
if (undefined !== jsonConfig.multiPass) { if (jsonConfig.multiPass) {
jsonConfig.multiPass = jsonConfig.multiPass.replace(/./g, '*'); jsonConfig.multiPass = jsonConfig.multiPass.replace(/./g, '*');
} }
const responseJSON = (JSONFormat) ? jsonConfig : ini.stringify(jsonConfig); const responseJSON = (JSONFormat) ? jsonConfig : ini.stringify(jsonConfig);

View file

@ -54,15 +54,15 @@ logoutRedirectLink=/login
;The environment variable can also be used for all of the above configurations except the UI settings. ;The environment variable can also be used for all of the above configurations except the UI settings.
;If the environment variables are set, it will take precedence over the parameters in the RTL.conf file. ;If the environment variables are set, it will take precedence over the parameters in the RTL.conf file.
PORT (port number for the rtl node server, default 3000) PORT (port number for the rtl node server, default 3000)
LND_SERVER_URL (LND server URL for REST APIs, default https://localhost:8080/v1)
MACAROON_PATH (Path for the folder containing 'admin.macaroon' file)
NODE_AUTH_TYPE (For stand alone RTL authentication allowed values - CUSTOM, DEFAULT) NODE_AUTH_TYPE (For stand alone RTL authentication allowed values - CUSTOM, DEFAULT)
LND_CONFIG_PATH (Full path of the lnd.conf file including the file name) RTL_PASS (Password for RTL custom authentication)
RTL_CONFIG_PATH (Full path of the RTL.conf file including the file name) LN_IMPLEMENTATION (LND, CLT. Default 'LND')
BITCOIND_CONFIG_PATH (Full path of the bitcoind.conf file including the file name) LND_SERVER_URL (LND server URL for REST APIs, default https://localhost:8080/v1) OR LN_SERVER_URL (LN server URL for LNP REST APIs)
LND_CONFIG_PATH (Full path of the lnd.conf file including the file name) OR CONFIG_PATH (Full path of the LNP .conf file including the file name)
MACAROON_PATH (Path for the folder containing 'admin.macaroon' file)
RTL_SSO (1 - single sign on via an external cookie, 0 - stand alone RTL authentication) RTL_SSO (1 - single sign on via an external cookie, 0 - stand alone RTL authentication)
RTL_COOKIE_PATH (Full path of the cookie file including the file name) RTL_COOKIE_PATH (Full path of the cookie file including the file name)
LOGOUT_REDIRECT_LINK (URL to re-direct to after logout/timeout from RTL) LOGOUT_REDIRECT_LINK (URL to re-direct to after logout/timeout from RTL)
CHANNEL_BACKUP_PATH (folder location for saving the channel backup files) RTL_CONFIG_PATH (Full path of the RTL.conf file including the file name)
FIAT_CONVERSION (Enable/Disable fiat conversion for the node, Default false) BITCOIND_CONFIG_PATH (Full path of the bitcoind.conf file including the file name)
CURRENCY_UNIT (Fiat currency unit for fiat conversion, Default 'USD' if FIAT_CONVERSION is true) CHANNEL_BACKUP_PATH (folder location for saving the channel backup files, valid for LND implementation only)

2251
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "rtl", "name": "rtl",
"version": "0.6.1-beta", "version": "0.6.2-beta",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
@ -54,7 +54,7 @@
"zone.js": "~0.9.1" "zone.js": "~0.9.1"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "~0.803.22", "@angular-devkit/build-angular": "^0.803.23",
"@angular/cli": "~8.3.22", "@angular/cli": "~8.3.22",
"@angular/compiler-cli": "~8.2.14", "@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14", "@angular/language-service": "~8.2.14",
@ -63,6 +63,7 @@
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4", "@types/node": "~8.9.4",
"codelyzer": "^5.0.0", "codelyzer": "^5.0.0",
"dotenv": "^8.2.0",
"jasmine-core": "~3.4.0", "jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0", "karma": "~4.1.0",
@ -70,7 +71,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1", "karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0", "karma-jasmine-html-reporter": "^1.4.0",
"node-sass": "^4.13.0", "node-sass": "^4.13.1",
"nodemon": "^2.0.2", "nodemon": "^2.0.2",
"protractor": "~5.4.0", "protractor": "~5.4.0",
"ts-node": "~7.0.0", "ts-node": "~7.0.0",