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

Incorrect value for X-Rate-Limit-Reset header in RateLimiter #15432

Closed
bizley opened this issue Dec 29, 2017 · 3 comments
Closed

Incorrect value for X-Rate-Limit-Reset header in RateLimiter #15432

bizley opened this issue Dec 29, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@bizley
Copy link
Member

bizley commented Dec 29, 2017

I suspect that method addRateLimitHeaders gets incorrect value for $reset argument resulting in incorrect header X-Rate-Limit-Reset value but I'm not sure of that because I can not believe no one noticed it for more than 3 years - please correct me if I'm wrong here.

What steps will reproduce the problem?

Implement methods from RateLimitInterface like in docs.
Set rate limit to [2, 10] (2 requests per 10 seconds).
Send request and check headers.

What is the expected result?

X-Rate-Limit-Limit = 2
X-Rate-Limit-Remaining = 1
X-Rate-Limit-Reset = 5

What do you get instead?

X-Rate-Limit-Limit = 2
X-Rate-Limit-Remaining = 1
X-Rate-Limit-Reset = 0

Additional info

According to docs X-Rate-Limit-Reset is

the number of seconds to wait in order to get the maximum number of allowed requests

Q A
Yii version 2.0.13.1
@samdark samdark added this to the 2.0.14 milestone Dec 30, 2017
@samdark samdark added the type:bug Bug label Dec 30, 2017
@samdark samdark self-assigned this Dec 30, 2017
@samdark
Copy link
Member

samdark commented Dec 30, 2017

You're not wrong :)

@samdark samdark closed this as completed Dec 30, 2017
samdark pushed a commit that referenced this issue Dec 30, 2017
…::checkRateLimit()` resulting in wrong `X-Rate-Limit-Reset` header value
@pujaydv
Copy link

pujaydv commented Jul 22, 2023

I have added rate limter config in our project but didn't get any below parameters in response headers
X-Rate-Limit-Limit
X-Rate-Limit-Remaining
X-Rate-Limit-Reset
Please any one guide me on this. How to implement ratelimiter in yii2.

@bizley
Copy link
Member Author

bizley commented Jul 23, 2023

Check 2 things (as in the guide):

  1. Implement RateLimitInterface for your user identity class.
  2. Either use rest based controller, or add rate limiter filter in the controller behaviors.

If this not help please ask at the forum.

@yiisoft yiisoft locked as resolved and limited conversation to collaborators Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants