1.0.7 • Published 7 years ago

gate-keep v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Express middleware for white/black listing IP Addresses

Getting Started


  • In the root of your express app create a .yaml file (You can name it whatever you want)
  • Define two sections
    • whitelist
    • blacklist
      • Look at priviledge.yaml in root of gate-keep for an example
  • List IP Addresses in sequence notation under each section

Example

var express = require('express'),
    app = express(),
    path = require('path');
    
var gatekeep = require('gate-keep');
gatekeep.setprivilege(path.join(__dirname, 'privilege.yaml')); //pass absolute path to .yaml allowed/blocked file

app.use(gatekeep.white.privilege); //Allows only the specified IP Address in privilege.yaml `whitelist` section
// Other configurations include
// app.use(gatekeep.black.privilege); Allows access to all IP Addresses except those listed in privilege.yaml `blacklist` section

/****************
 * Other stuff **
 ****************/
 
// gate-keep passes a `err` to next() when the IP is restricted so you 
// need to define an error handler to catch it
app.use(function(err, req, res, next){
    res.status(403);
    res.send('Denied');
});

app.listen(3000);
1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago