-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from openstad/development
Development
- Loading branch information
Showing
9 changed files
with
3,381 additions
and
5,900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const Netmask = require('netmask').Netmask; | ||
|
||
exports.preventCiscoRequest = (req, res, next) => { | ||
|
||
// Fix for local IP | ||
if (req.ip == '::1') { | ||
return next(); | ||
} | ||
|
||
// Get CIDRs from client config. If the `blockCidrs` key doesn't exist fall back to Cisco Umbrella CIDRs | ||
// See https://support.umbrella.com/hc/en-us/articles/360059292052-Additional-Egress-IP-Address-Range | ||
const blockCidrs = req && req.client && req.client.config && req.client.config.blockCidrs ? req.client.config.blockCidrs : ['146.112.0.0/16', '155.190.0.0/16', '151.186.0.0/16']; | ||
|
||
// Check if IP is in cidr | ||
const isIpInCidr = blockCidrs.some(cidr => { | ||
const block = new Netmask(cidr); | ||
return block.contains(req.ip); | ||
}); | ||
|
||
if (!isIpInCidr) { | ||
return next(); | ||
} | ||
|
||
console.log('IP is in CIDRs to block', req.ip, blockCidrs, isIpInCidr); | ||
|
||
req.flash('error', {msg: 'De url is geen geldige login url, wellicht is deze verlopen'}); | ||
return res.redirect(`/auth/url/login?clientId=${req.query.clientId}`); | ||
|
||
} |
Oops, something went wrong.
9f61bc4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published new image:
openstad/auth:master-9f61bc4
9f61bc4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published new image:
openstad/auth:development-9f61bc4
9f61bc4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published new image:
openstad/auth:hotfix-invalid-redirect-url-9f61bc4