Add Disable Authentication option in the backend

This commit is contained in:
ShahanaFarooqui 2026-03-25 20:27:25 -07:00 committed by Suheb
parent 7d32bd68e9
commit 4613b889bf
6 changed files with 37 additions and 5 deletions

View file

@ -52,7 +52,12 @@ export const verifyToken = (twoFAToken) => !!(common.appConfig.secret2FA && comm
export const authenticateUser = (req, res, next) => {
const { authenticateWith, authenticationValue, twoFAToken } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..' });
if (+common.appConfig.SSO.rtlSSO) {
if (!!common.appConfig.disableAuth) {
if (!req.session.selectedNode) { req.session.selectedNode = common.selectedNode; }
const token = jwt.sign({ user: 'AUTH_DISABLED_USER' }, common.secret_key);
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'User Disabled Authentication' });
res.status(200).json({ token: token });
} else if (+common.appConfig.SSO.rtlSSO) {
if (authenticateWith === 'JWT' && jwt.verify(authenticationValue, common.secret_key)) {
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.' });

View file

@ -55,6 +55,7 @@ export class ApplicationConfig {
public selectedNodeIndex: number,
public dbDirectoryPath?: string,
public rtlConfFilePath?: string,
public disableAuth?: boolean,
public rtlPass?: string,
public multiPass?: string,
public multiPassHashed?: string,

View file

@ -126,9 +126,17 @@ export class ConfigService {
private validateNodeConfig = (config) => {
config.allowPasswordUpdate = true;
if ((process?.env?.RTL_SSO && +process?.env?.RTL_SSO === 0) || (typeof process?.env?.RTL_SSO === 'undefined' && +config.SSO.rtlSSO === 0)) {
if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
if (!!process?.env?.DISABLE_AUTH || !!config.disableAuth) {
config.allowPasswordUpdate = false;
config.enable2FA = false;
this.logger.log({ selectedNode: this.common.selectedNode, level: 'WARN', fileName: 'Config', msg: 'Authentication is Disabled via environment or config' });
if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
this.errMsg = this.errMsg + '\nRTL Password cannot be set with disabled authentication. Please remove disableAuth option or password.';
}
} else if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
config.rtlPass = this.hash.update(process?.env?.APP_PASSWORD).digest('hex');
config.allowPasswordUpdate = false;
this.logger.log({ selectedNode: this.common.selectedNode, level: 'WARN', fileName: 'Config', msg: 'Passing APP_PASSWORD via environment is suggested for standalone RTL application' });
} else if (config.multiPassHashed && config.multiPassHashed !== '') {
config.rtlPass = config.multiPassHashed;
} else if (config.multiPass && config.multiPass !== '') {