StevenThuriot / express-rate-limiter

Rate limiter middleware for express applications
https://www.npmjs.org/package/express-rate-limiter
MIT License
5 stars 4 forks source link

Different key attribute #15

Open Christilut opened 7 years ago

Christilut commented 7 years ago

Is it possible to change the key to something else instead of IP address?

In my case, middleware adds the logged in user to each request, so it would be nice if I could use req.user._id as key instead of IP. Even better if this could be a function where I can let it fall back to IP address when req.user is null.

This is just incase multiple users are behind the same IP address and want them to hit the limiter for no reason.

StevenThuriot commented 7 years ago

Hi!

I like your suggestion, it's definitely useful. But as I'm currently on holiday, I can't implement this right now. I am however more than happy to accept a pull request!