Skip to content
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

Global API limit #74

Open
pesseyjulien opened this issue Aug 1, 2018 · 7 comments
Open

Global API limit #74

pesseyjulien opened this issue Aug 1, 2018 · 7 comments

Comments

@pesseyjulien
Copy link

pesseyjulien commented Aug 1, 2018

Hi,

How to make a global rate limit. I can only make it work using Controller annotation per method. Here is my config :
capture d ecran 2018-08-01 a 17 33 02

Thanks in advance,
Julien

@pesseyjulien pesseyjulien changed the title The service "noxlogic_rate_limit.storage" has a dependency on a non-existent service "". Redis storage engine not working Aug 1, 2018
@pesseyjulien pesseyjulien changed the title Redis storage engine not working Global API limit Aug 1, 2018
@pesseyjulien pesseyjulien reopened this Aug 1, 2018
@jason-linthwaite
Copy link

+1 to this. I have set the "path_limits" in the config file to my root API path but it seems to have no effect.
I don't want to have to specify this on every controller. Is this the intended action? If so, why require the path limits config?

@ndench
Copy link

ndench commented Oct 22, 2019

This issue is pretty old now. Has anyone fond a way to achieve a global rate limit?

@pesseyjulien
Copy link
Author

path_limits:
- { path: /, limit: 1000, period: 3600 }

@goetas
Copy link
Collaborator

goetas commented Oct 22, 2019

You have the full config list at https://github.com/jaytaph/RateLimitBundle#configuration-reference

@ndench
Copy link

ndench commented Oct 25, 2019 via email

@stefanides
Copy link

Hi, I am trying to use pesseyjulien's solution above for global limit for all routes. Once the path config contains something more than '/', the PathLimitProcessor compares it by parts in pathMatched() method and it works fine as prefix. However, when the path is just '/', it gets trimmed in constructor to an empty string and then pathMatched() compares '' to any string present in URL, which is false - except the homepage path itself. The same can be seen watching http headers - they are present only for '/' route and no other/longer path. Should there be some more test for this scenario inside pathMatched() like
if (count($expectedParts) == 1 && $expectedParts[0] == '') { return true; }
?
Then also the constructor needs to be updated - to sort '' lower than 'xyz' paths even they have the same substr_count(), current code keeps the original sort from config file.

Tested on "version": "1.15.1"

@abarkine
Copy link
Contributor

abarkine commented Apr 7, 2021

This issue can be closed as it seems like #119

New usage:

path_limits:
- { path: *, method: *, limit: 1000, period: 3600 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants