mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2024-11-19 01:40:29 +01:00
Read RTL Config from common.appConfig not from rtlConfFilePath
Reading from config file was overwriting the environment variables. Fixed it by reading the values from already updated common.appConfig.
This commit is contained in:
parent
f02f0c00dd
commit
f38c4b53cf
2
.github/workflows/docker-release.yml
vendored
2
.github/workflows/docker-release.yml
vendored
@ -44,7 +44,7 @@ jobs:
|
|||||||
echo "GITHUB REF TYPE: ${{ github.ref_type }}"
|
echo "GITHUB REF TYPE: ${{ github.ref_type }}"
|
||||||
echo "GITHUB REF NAME: ${{ github.ref_name }}"
|
echo "GITHUB REF NAME: ${{ github.ref_name }}"
|
||||||
echo "EVENT INPUT VERSION: ${{ github.event.inputs.version }}"
|
echo "EVENT INPUT VERSION: ${{ github.event.inputs.version }}"
|
||||||
echo "ENV VERSION: ${{ env.VERSION }}"
|
echo "ENV VERSION: $VERSION"
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -21,10 +21,6 @@
|
|||||||
|
|
||||||
# IDE - VSCode
|
# IDE - VSCode
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/settings.json
|
|
||||||
!.vscode/tasks.json
|
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/extensions.json
|
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
/.angular/cache
|
/.angular/cache
|
||||||
|
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "pwa-node",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Launch Program",
|
|
||||||
"skipFiles": [
|
|
||||||
"<node_internals>/**"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "development"
|
|
||||||
},
|
|
||||||
"program": "${workspaceFolder}/rtl.js"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"eslint.enable": true,
|
|
||||||
"eslint.validate": [
|
|
||||||
"typescript",
|
|
||||||
"HTML"
|
|
||||||
],
|
|
||||||
"eslint.options": {
|
|
||||||
"configFile": ".eslintrc.json"
|
|
||||||
},
|
|
||||||
"editor.codeActionsOnSave": {
|
|
||||||
"source.fixAll.eslint": "explicit"
|
|
||||||
}
|
|
||||||
}
|
|
@ -96,43 +96,33 @@ export const getFile = (req, res, next) => {
|
|||||||
};
|
};
|
||||||
export const getApplicationSettings = (req, res, next) => {
|
export const getApplicationSettings = (req, res, next) => {
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..' });
|
||||||
const confFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
|
const appConfData = common.removeSecureData(JSON.parse(JSON.stringify(common.appConfig)));
|
||||||
fs.readFile(confFile, 'utf8', (errRes, data) => {
|
appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate;
|
||||||
if (errRes) {
|
appConfData.enable2FA = common.appConfig.enable2FA;
|
||||||
const errMsg = 'Get Node Config Error';
|
appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index);
|
||||||
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
|
common.appConfig.selectedNodeIndex = appConfData.selectedNodeIndex;
|
||||||
return res.status(err.statusCode).json({ message: err.error, error: err.error });
|
const token = req.headers.authorization ? req.headers.authorization.split(' ')[1] : '';
|
||||||
}
|
jwt.verify(token, common.secret_key, (err, user) => {
|
||||||
else {
|
if (err) {
|
||||||
const appConfData = common.removeSecureData(JSON.parse(data));
|
// Delete unnecessary data for initial response (without security token)
|
||||||
appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate;
|
const selNodeIdx = appConfData.nodes.findIndex((node) => node.index === appConfData.selectedNodeIndex) || 0;
|
||||||
appConfData.enable2FA = common.appConfig.enable2FA;
|
delete appConfData.SSO.rtlCookiePath;
|
||||||
appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index);
|
delete appConfData.SSO.cookieValue;
|
||||||
common.appConfig.selectedNodeIndex = appConfData.selectedNodeIndex;
|
delete appConfData.SSO.logoutRedirectLink;
|
||||||
const token = req.headers.authorization ? req.headers.authorization.split(' ')[1] : '';
|
appConfData.secret2FA = '';
|
||||||
jwt.verify(token, common.secret_key, (err, user) => {
|
appConfData.dbDirectoryPath = '';
|
||||||
if (err) {
|
appConfData.nodes[selNodeIdx].authentication = new Authentication();
|
||||||
// Delete unnecessary data for initial response (without security token)
|
delete appConfData.nodes[selNodeIdx].settings.bitcoindConfigPath;
|
||||||
const selNodeIdx = appConfData.nodes.findIndex((node) => node.index === appConfData.selectedNodeIndex) || 0;
|
delete appConfData.nodes[selNodeIdx].settings.lnServerUrl;
|
||||||
delete appConfData.SSO.rtlCookiePath;
|
delete appConfData.nodes[selNodeIdx].settings.swapServerUrl;
|
||||||
delete appConfData.SSO.cookieValue;
|
delete appConfData.nodes[selNodeIdx].settings.boltzServerUrl;
|
||||||
delete appConfData.SSO.logoutRedirectLink;
|
delete appConfData.nodes[selNodeIdx].settings.enableOffers;
|
||||||
appConfData.secret2FA = '';
|
delete appConfData.nodes[selNodeIdx].settings.enablePeerswap;
|
||||||
appConfData.dbDirectoryPath = '';
|
delete appConfData.nodes[selNodeIdx].settings.channelBackupPath;
|
||||||
appConfData.nodes[selNodeIdx].authentication = new Authentication();
|
appConfData.nodes = [appConfData.nodes[selNodeIdx]];
|
||||||
delete appConfData.nodes[selNodeIdx].settings.bitcoindConfigPath;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.lnServerUrl;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.swapServerUrl;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.boltzServerUrl;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.enableOffers;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.enablePeerswap;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.channelBackupPath;
|
|
||||||
appConfData.nodes = [appConfData.nodes[selNodeIdx]];
|
|
||||||
}
|
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received', data: appConfData });
|
|
||||||
res.status(200).json(appConfData);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received', data: appConfData });
|
||||||
|
res.status(200).json(appConfData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export const updateSelectedNode = (req, res, next) => {
|
export const updateSelectedNode = (req, res, next) => {
|
||||||
|
@ -48,7 +48,7 @@ export const verifyToken = (twoFAToken) => !!(common.appConfig.secret2FA && comm
|
|||||||
export const authenticateUser = (req, res, next) => {
|
export const authenticateUser = (req, res, next) => {
|
||||||
const { authenticateWith, authenticationValue, twoFAToken } = req.body;
|
const { authenticateWith, authenticationValue, twoFAToken } = req.body;
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..' });
|
||||||
if (+common.appConfig.SSO.rtlSso) {
|
if (+common.appConfig.SSO.rtlSSO) {
|
||||||
if (authenticateWith === 'JWT' && jwt.verify(authenticationValue, common.secret_key)) {
|
if (authenticateWith === 'JWT' && jwt.verify(authenticationValue, common.secret_key)) {
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated' });
|
||||||
res.status(406).json({ message: 'SSO Authentication Error', error: 'Login with Password is not allowed with SSO.' });
|
res.status(406).json({ message: 'SSO Authentication Error', error: 'Login with Password is not allowed with SSO.' });
|
||||||
@ -103,7 +103,7 @@ export const authenticateUser = (req, res, next) => {
|
|||||||
export const resetPassword = (req, res, next) => {
|
export const resetPassword = (req, res, next) => {
|
||||||
const { currPassword, newPassword } = req.body;
|
const { currPassword, newPassword } = req.body;
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Resetting Password..' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Resetting Password..' });
|
||||||
if (+common.appConfig.SSO.rtlSso) {
|
if (+common.appConfig.SSO.rtlSSO) {
|
||||||
const errMsg = 'Password cannot be reset for SSO authentication';
|
const errMsg = 'Password cannot be reset for SSO authentication';
|
||||||
const err = common.handleError({ statusCode: 401, message: 'Password Reset Error', error: errMsg }, 'Authenticate', errMsg, req.session.selectedNode);
|
const err = common.handleError({ statusCode: 401, message: 'Password Reset Error', error: errMsg }, 'Authenticate', errMsg, req.session.selectedNode);
|
||||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export class SSO {
|
export class SSO {
|
||||||
constructor(rtlSso, rtlCookiePath, logoutRedirectLink, cookieValue) {
|
constructor(rtlSSO, rtlCookiePath, logoutRedirectLink, cookieValue) {
|
||||||
this.rtlSso = rtlSso;
|
this.rtlSSO = rtlSSO;
|
||||||
this.rtlCookiePath = rtlCookiePath;
|
this.rtlCookiePath = rtlCookiePath;
|
||||||
this.logoutRedirectLink = logoutRedirectLink;
|
this.logoutRedirectLink = logoutRedirectLink;
|
||||||
this.cookieValue = cookieValue;
|
this.cookieValue = cookieValue;
|
||||||
|
@ -9,7 +9,7 @@ export class CommonService {
|
|||||||
this.logger = Logger;
|
this.logger = Logger;
|
||||||
this.nodes = [];
|
this.nodes = [];
|
||||||
this.selectedNode = null;
|
this.selectedNode = null;
|
||||||
this.ssoInit = { rtlSso: 0, rtlCookiePath: '', logoutRedirectLink: '', cookieValue: '' };
|
this.ssoInit = { rtlSSO: 0, rtlCookiePath: '', logoutRedirectLink: '', cookieValue: '' };
|
||||||
this.appConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, secret2FA: '', SSO: this.ssoInit, nodes: [] };
|
this.appConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, secret2FA: '', SSO: this.ssoInit, nodes: [] };
|
||||||
this.port = 3000;
|
this.port = 3000;
|
||||||
this.host = '';
|
this.host = '';
|
||||||
@ -528,7 +528,7 @@ export class CommonService {
|
|||||||
const selNode = req.session.selectedNode;
|
const selNode = req.session.selectedNode;
|
||||||
if (selNode && selNode.index) {
|
if (selNode && selNode.index) {
|
||||||
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup:', msg: JSON.stringify(this.removeSecureData(JSON.parse(JSON.stringify(this.appConfig)))) });
|
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup:', msg: JSON.stringify(this.removeSecureData(JSON.parse(JSON.stringify(this.appConfig)))) });
|
||||||
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'SSO: ' + this.appConfig.SSO.rtlSso });
|
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'SSO: ' + this.appConfig.SSO.rtlSSO });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.filterData = (dataKey, lnImplementation) => {
|
this.filterData = (dataKey, lnImplementation) => {
|
||||||
|
@ -318,10 +318,10 @@ export class ConfigService {
|
|||||||
};
|
};
|
||||||
this.setSSOParams = (config) => {
|
this.setSSOParams = (config) => {
|
||||||
if (process?.env?.RTL_SSO) {
|
if (process?.env?.RTL_SSO) {
|
||||||
config.SSO.rtlSso = +process?.env?.RTL_SSO;
|
config.SSO.rtlSSO = +process?.env?.RTL_SSO;
|
||||||
}
|
}
|
||||||
else if (config.SSO && config.SSO.rtlSSO) {
|
else if (config.SSO && config.SSO.rtlSSO) {
|
||||||
config.SSO.rtlSso = config.SSO.rtlSSO;
|
config.SSO.rtlSSO = config.SSO.rtlSSO;
|
||||||
}
|
}
|
||||||
if (process?.env?.RTL_COOKIE_PATH) {
|
if (process?.env?.RTL_COOKIE_PATH) {
|
||||||
config.SSO.rtlCookiePath = process?.env?.RTL_COOKIE_PATH;
|
config.SSO.rtlCookiePath = process?.env?.RTL_COOKIE_PATH;
|
||||||
@ -338,7 +338,7 @@ export class ConfigService {
|
|||||||
else if (config.SSO && config.SSO.logoutRedirectLink) {
|
else if (config.SSO && config.SSO.logoutRedirectLink) {
|
||||||
config.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
|
config.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
|
||||||
}
|
}
|
||||||
if (+config.SSO.rtlSso) {
|
if (+config.SSO.rtlSSO) {
|
||||||
if (!config.SSO.rtlCookiePath || config.SSO.rtlCookiePath.trim() === '') {
|
if (!config.SSO.rtlCookiePath || config.SSO.rtlCookiePath.trim() === '') {
|
||||||
this.errMsg = 'Please set rtlCookiePath value for single sign on option!';
|
this.errMsg = 'Please set rtlCookiePath value for single sign on option!';
|
||||||
}
|
}
|
||||||
|
@ -99,42 +99,33 @@ export const getFile = (req, res, next) => {
|
|||||||
|
|
||||||
export const getApplicationSettings = (req, res, next) => {
|
export const getApplicationSettings = (req, res, next) => {
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..' });
|
||||||
const confFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
|
const appConfData = common.removeSecureData(JSON.parse(JSON.stringify(common.appConfig)));
|
||||||
fs.readFile(confFile, 'utf8', (errRes, data) => {
|
appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate;
|
||||||
if (errRes) {
|
appConfData.enable2FA = common.appConfig.enable2FA;
|
||||||
const errMsg = 'Get Node Config Error';
|
appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index);
|
||||||
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
|
common.appConfig.selectedNodeIndex = appConfData.selectedNodeIndex;
|
||||||
return res.status(err.statusCode).json({ message: err.error, error: err.error });
|
const token = req.headers.authorization ? req.headers.authorization.split(' ')[1] : '';
|
||||||
} else {
|
jwt.verify(token, common.secret_key, (err, user) => {
|
||||||
const appConfData = common.removeSecureData(JSON.parse(data));
|
if (err) {
|
||||||
appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate;
|
// Delete unnecessary data for initial response (without security token)
|
||||||
appConfData.enable2FA = common.appConfig.enable2FA;
|
const selNodeIdx = appConfData.nodes.findIndex((node) => node.index === appConfData.selectedNodeIndex) || 0;
|
||||||
appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index);
|
delete appConfData.SSO.rtlCookiePath;
|
||||||
common.appConfig.selectedNodeIndex = appConfData.selectedNodeIndex;
|
delete appConfData.SSO.cookieValue;
|
||||||
const token = req.headers.authorization ? req.headers.authorization.split(' ')[1] : '';
|
delete appConfData.SSO.logoutRedirectLink;
|
||||||
jwt.verify(token, common.secret_key, (err, user) => {
|
appConfData.secret2FA = '';
|
||||||
if (err) {
|
appConfData.dbDirectoryPath = '';
|
||||||
// Delete unnecessary data for initial response (without security token)
|
appConfData.nodes[selNodeIdx].authentication = new Authentication();
|
||||||
const selNodeIdx = appConfData.nodes.findIndex((node) => node.index === appConfData.selectedNodeIndex) || 0;
|
delete appConfData.nodes[selNodeIdx].settings.bitcoindConfigPath;
|
||||||
delete appConfData.SSO.rtlCookiePath;
|
delete appConfData.nodes[selNodeIdx].settings.lnServerUrl;
|
||||||
delete appConfData.SSO.cookieValue;
|
delete appConfData.nodes[selNodeIdx].settings.swapServerUrl;
|
||||||
delete appConfData.SSO.logoutRedirectLink;
|
delete appConfData.nodes[selNodeIdx].settings.boltzServerUrl;
|
||||||
appConfData.secret2FA = '';
|
delete appConfData.nodes[selNodeIdx].settings.enableOffers;
|
||||||
appConfData.dbDirectoryPath = '';
|
delete appConfData.nodes[selNodeIdx].settings.enablePeerswap;
|
||||||
appConfData.nodes[selNodeIdx].authentication = new Authentication();
|
delete appConfData.nodes[selNodeIdx].settings.channelBackupPath;
|
||||||
delete appConfData.nodes[selNodeIdx].settings.bitcoindConfigPath;
|
appConfData.nodes = [appConfData.nodes[selNodeIdx]];
|
||||||
delete appConfData.nodes[selNodeIdx].settings.lnServerUrl;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.swapServerUrl;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.boltzServerUrl;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.enableOffers;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.enablePeerswap;
|
|
||||||
delete appConfData.nodes[selNodeIdx].settings.channelBackupPath;
|
|
||||||
appConfData.nodes = [appConfData.nodes[selNodeIdx]];
|
|
||||||
}
|
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received', data: appConfData });
|
|
||||||
res.status(200).json(appConfData);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received', data: appConfData });
|
||||||
|
res.status(200).json(appConfData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ export const verifyToken = (twoFAToken) => !!(common.appConfig.secret2FA && comm
|
|||||||
export const authenticateUser = (req, res, next) => {
|
export const authenticateUser = (req, res, next) => {
|
||||||
const { authenticateWith, authenticationValue, twoFAToken } = req.body;
|
const { authenticateWith, authenticationValue, twoFAToken } = req.body;
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..' });
|
||||||
if (+common.appConfig.SSO.rtlSso) {
|
if (+common.appConfig.SSO.rtlSSO) {
|
||||||
if (authenticateWith === 'JWT' && jwt.verify(authenticationValue, common.secret_key)) {
|
if (authenticateWith === 'JWT' && jwt.verify(authenticationValue, common.secret_key)) {
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated' });
|
||||||
res.status(406).json({ message: 'SSO Authentication Error', error: 'Login with Password is not allowed with SSO.' });
|
res.status(406).json({ message: 'SSO Authentication Error', error: 'Login with Password is not allowed with SSO.' });
|
||||||
@ -100,7 +100,7 @@ export const authenticateUser = (req, res, next) => {
|
|||||||
export const resetPassword = (req, res, next) => {
|
export const resetPassword = (req, res, next) => {
|
||||||
const { currPassword, newPassword } = req.body;
|
const { currPassword, newPassword } = req.body;
|
||||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Resetting Password..' });
|
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Resetting Password..' });
|
||||||
if (+common.appConfig.SSO.rtlSso) {
|
if (+common.appConfig.SSO.rtlSSO) {
|
||||||
const errMsg = 'Password cannot be reset for SSO authentication';
|
const errMsg = 'Password cannot be reset for SSO authentication';
|
||||||
const err = common.handleError({ statusCode: 401, message: 'Password Reset Error', error: errMsg }, 'Authenticate', errMsg, req.session.selectedNode);
|
const err = common.handleError({ statusCode: 401, message: 'Password Reset Error', error: errMsg }, 'Authenticate', errMsg, req.session.selectedNode);
|
||||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export class SSO {
|
export class SSO {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public rtlSso?: number,
|
public rtlSSO?: number,
|
||||||
public rtlCookiePath?: string,
|
public rtlCookiePath?: string,
|
||||||
public logoutRedirectLink?: string,
|
public logoutRedirectLink?: string,
|
||||||
public cookieValue?: string
|
public cookieValue?: string
|
||||||
|
@ -11,7 +11,7 @@ export class CommonService {
|
|||||||
public logger: LoggerService = Logger;
|
public logger: LoggerService = Logger;
|
||||||
public nodes: SelectedNode[] = [];
|
public nodes: SelectedNode[] = [];
|
||||||
public selectedNode: SelectedNode = null;
|
public selectedNode: SelectedNode = null;
|
||||||
public ssoInit = { rtlSso: 0, rtlCookiePath: '', logoutRedirectLink: '', cookieValue: '' };
|
public ssoInit = { rtlSSO: 0, rtlCookiePath: '', logoutRedirectLink: '', cookieValue: '' };
|
||||||
public appConfig: ApplicationConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, secret2FA: '', SSO: this.ssoInit, nodes: [] };
|
public appConfig: ApplicationConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, secret2FA: '', SSO: this.ssoInit, nodes: [] };
|
||||||
public port = 3000;
|
public port = 3000;
|
||||||
public host = '';
|
public host = '';
|
||||||
@ -542,7 +542,7 @@ export class CommonService {
|
|||||||
const selNode = <SelectedNode>req.session.selectedNode;
|
const selNode = <SelectedNode>req.session.selectedNode;
|
||||||
if (selNode && selNode.index) {
|
if (selNode && selNode.index) {
|
||||||
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup:', msg: JSON.stringify(this.removeSecureData(JSON.parse(JSON.stringify(this.appConfig)))) });
|
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup:', msg: JSON.stringify(this.removeSecureData(JSON.parse(JSON.stringify(this.appConfig)))) });
|
||||||
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'SSO: ' + this.appConfig.SSO.rtlSso });
|
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'SSO: ' + this.appConfig.SSO.rtlSSO });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -298,9 +298,9 @@ export class ConfigService {
|
|||||||
|
|
||||||
private setSSOParams = (config) => {
|
private setSSOParams = (config) => {
|
||||||
if (process?.env?.RTL_SSO) {
|
if (process?.env?.RTL_SSO) {
|
||||||
config.SSO.rtlSso = +process?.env?.RTL_SSO;
|
config.SSO.rtlSSO = +process?.env?.RTL_SSO;
|
||||||
} else if (config.SSO && config.SSO.rtlSSO) {
|
} else if (config.SSO && config.SSO.rtlSSO) {
|
||||||
config.SSO.rtlSso = config.SSO.rtlSSO;
|
config.SSO.rtlSSO = config.SSO.rtlSSO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process?.env?.RTL_COOKIE_PATH) {
|
if (process?.env?.RTL_COOKIE_PATH) {
|
||||||
@ -317,7 +317,7 @@ export class ConfigService {
|
|||||||
config.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
|
config.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (+config.SSO.rtlSso) {
|
if (+config.SSO.rtlSSO) {
|
||||||
if (!config.SSO.rtlCookiePath || config.SSO.rtlCookiePath.trim() === '') {
|
if (!config.SSO.rtlCookiePath || config.SSO.rtlCookiePath.trim() === '') {
|
||||||
this.errMsg = 'Please set rtlCookiePath value for single sign on option!';
|
this.errMsg = 'Please set rtlCookiePath value for single sign on option!';
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user