Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

574 B
Raw Blame
const isTrustedProxy = require('../utils/trusted-proxy');

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