chamini2 / hapi-auth-ip-whitelist Goto Github PK
View Code? Open in Web Editor NEWHapi.js plugin for authentication scheme of accepting connections only from certain IPs
License: MIT License
Hapi.js plugin for authentication scheme of accepting connections only from certain IPs
License: MIT License
The ip
library that you are using doesn't match IPv4 ranges written in CIDR notation, this results in "Internal Server Error" when using hapi-auth-ip-whitelist
.
The ip
source code:
var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
ip.isV4Format = function(ip) {
return ipv4Regex.test(ip);
};
Clearly the regex will never match a CIDR IP range.
https://github.com/indutny/node-ip/blob/43e442366bf5a93493c8c4c36736f87d675b0c3d/lib/ip.js#L87
Hi!
Is there any progress on supporting hapi v16 and v17? It contains breaking changes which makes the plugin incompatible so it would be nice to perform the upgrade as well.
If you haven't started this yet I feel I can provide a PR by the end of this week โ๏ธ
I have tested the library with an API deployed in AWS but it always is saying that receives requests from "127.0.0.1" localhost. Is there a way to make it recognize the real IP for the request
I have used this code in the past to extract real IP from requests:
const ip = request.headers['x-forwarded-for'] ? request.headers['x-forwarded-for'].split(',')[0] : request.headers['x-real-ip'] || request.info.remoteAddress
Test environment I don't want to verify any IP address, how to do it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.