dashy/services/get-user.js
2024-04-28 20:00:17 +01:00

16 lines
490 B
JavaScript

module.exports = (config, req) => {
try {
if (config.appConfig.auth.enableHeaderAuth) {
const { userHeader } = config.appConfig.auth.headerAuth;
const { proxyWhitelist } = config.appConfig.auth.headerAuth;
if (proxyWhitelist.includes(req.socket.remoteAddress)) {
return { success: true, user: req.headers[userHeader.toLowerCase()] };
}
}
return {};
} catch (e) {
console.warn('Error get-user: ', e);
return { success: false };
}
};