From ed83e014cd3681657451ac7a2120f7d30c363c66 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Wed, 6 Sep 2017 04:07:50 -0500 Subject: [PATCH] Implement IP range restrictions --- app.js | 6 ++++++ config/glass_config.json | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index a27c3ca..b1a4d81 100644 --- a/app.js +++ b/app.js @@ -21,6 +21,12 @@ app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); +if(glass_config.ip_ranges_to_allow) { + var ip_filter = require('express-ipfilter').IpFilter; + var ips = glass_config.ip_ranges_to_allow; + app.use(ip_filter(ips, {mode: 'allow'})); +} + /* Normal Web Routes */ app.use('/', require('./routes/index')); app.use('/users', require('./routes/users')); diff --git a/config/glass_config.json b/config/glass_config.json index 9ea9574..159e611 100644 --- a/config/glass_config.json +++ b/config/glass_config.json @@ -8,5 +8,6 @@ "shared_network_warning_threshold": "80", "slack_webhook_url": "https://hooks.slack.com/services/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", "slack_alert_channel": "#alerting", - "leases_per_minute_threshold": "1000" + "leases_per_minute_threshold": "1000", + "ip_ranges_to_allow": [""] }