-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add express rate limiting #8170
Comments
Thanks for opening this issue!
|
How does this work if there are multiple Parse Server instances behind a load balancer? Is the |
https://github.com/nfriedly/express-rate-limit#troubleshooting-proxy-issues |
Let's say the server instances are behind a load balancer on AWS or GCP, which is a common scenario. Every server would calculate their rate limit by only considering the request itself handled, without considering requests handled by other instances, correct? |
That is correct. In that case, wouldn't using AWS WAF/Cloudflare be preferred for rate limiting |
Yes, that's an important limitation we need to explain in the docs; in the future we could overcome this by logging requests in Redis for example, but we are getting into a complex territory which is far from the core functionality of Parse Server and I don't think we should go there. It's also not the best approach to limit on the application layer, a DoS that reached so far already caused some damage. Also, does |
Yes, I think this is why in the past we have recommended rate limiting at nginx. However I think a per IP rate limit is still better than nothing and has some practical use for specific use cases, such as only allowing one IP to call a cloud function once a day, for example. We can actually make the rate limit so it links per sessionToken or user for example, so the proxy issues would be resolved. |
I agree that adding a simple rate limiting feature for Parse Server which run as a single instance (w/o load balancer) makes sense. I think the basis for rate limiting needs to be a basic, common key that all requests have. A session token is unavailable if the request is anonymous. Maybe we should stick with the per-IP address feature and consider it "a simple rate-limiting implementation that is better than nothing and covers a single-instance server scenario in case of a not very sophisticated DoS attack." That means, if someone starts to develop their first project and deploys Parse Server somewhere, they can easily add a simple layer of protection. We should remember to clarify that all in the docs. |
We can use mongoDB as an optional store which would help for multiple instances. We could do IP address if session is undefined, otherwise In the case of limiting the global amount of requests per second (regardless of IP/user), we can add that too. We would just need to add a global rateLimit with the Perhaps we could add a parameter for
This would let the developer define how they want the restriction to function. Another option could be a slowdown: https://www.npmjs.com/package/express-slow-down |
Let's limit the scope to a simple version of this feature with rate limiting per IP. All the other ideas are worth to be discussed at some point, but too complex for an initial feature release. I have doubts regarding using MongoDB as a cache and mixing IP address with session tokens for limiting, or even slowing down requests, which can create complex issues with the timeout configuration in a load balancer architecture. |
Ok, no worries. Should we still have the option for the limit to be global, regardless of IP (ddos protection)? |
Let’s leave it with IP for now for a basic protection, we can always add more features later on. |
🎉 This change has been released in version 6.0.0-alpha.21 |
🎉 This change has been released in version 6.0.0-beta.1 |
🎉 This change has been released in version 6.0.0 |
New Feature / Enhancement Checklist
Current Limitation
Rate limiting an API is something that is usually done by a separate part in an architecture, before it even reaches Parse Server. The earlier a rate limiting is enforced to prevent DOS attacks, the lower the impact of such an attack. However, not every developer may have the experience or availability of such rate-limiting components.
Feature / Enhancement Description
Parse Server should offer a basic feature for rate limiting:
Example Use Case
The following example shows an Express application that serves static files without rate limiting:
To prevent denial-of-service attacks, the express-rate-limit package can be used:
Alternatives / Workarounds
Require developer to implement a custom rate-limiter.
3rd Party References
The text was updated successfully, but these errors were encountered: