1.1.0 • Published 5 years ago

ip_whitelisting_middleware v1.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

This middleware is used to pass a flag for whitelisted ips setted in process.env variable.

(ips) => {

  return (req, res, next) => {

   const ip = req.get('X-Forwarded-For') || req.ip;
    if (!ips) {
      ips = '';
    }

    let whitelistedIps = ips.split(',');

    if (whitelistedIps.length > 0) {
      whitelistedIps = whitelistedIps.map(ip =>  ip.trim());
    }

    req.whitelistedIp = false;

    if (ipRangeCheck(String(ip), whitelistedIps)) {
      req.whitelistedIp = true;
    }

    next();
  }
};
1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago