Make userHeader pull from config

This commit is contained in:
Todd E Johnson
2023-11-23 00:02:08 -06:00
parent 4aa34f66dc
commit 27dfe6219a
3 changed files with 16 additions and 7 deletions

View File

@@ -99,10 +99,11 @@ const printFileReadError = (e) => {
};
try { // Try to open and parse the YAML file
const config = yaml.load(fs.readFileSync('./public/conf.yml', 'utf8'));
config = yaml.load(fs.readFileSync('./public/conf.yml', 'utf8'));
validate(config);
} catch (e) { // Something went very wrong...
setIsValidVariable(false);
logToConsole(bigError());
printFileReadError(e);
}
module.exports = config;

View File

@@ -1,5 +1,11 @@
module.exports = (req) => {
const userHeader = "Remote-User";
console.log("Running Server Side", req.headers[userHeader.toLowerCase()]); // eslint-disable-line no-console
return { "success": true, "user": req.headers[userHeader.toLowerCase()] };
module.exports = (config, req) => {
try {
if ( config.appConfig.auth.enableHeaderAuth ) {
const userHeader = config.appConfig.auth.headerAuth.userHeader;
return { "success": true, "user": req.headers[userHeader.toLowerCase()] };
}
} catch (e) {
console.warn("Error get-user: ", e);
return { 'success': false };
}
};