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

[10.x] Add shouldHashKeys to ThrottleRequests middleware #47368

Merged
merged 7 commits into from Jun 8, 2023

Conversation

fosron
Copy link
Contributor

@fosron fosron commented Jun 7, 2023

This adds ability to have rate limiter keys in a non hashed format. I believe there is no added benefit of having those hashed using md5 or sha1 most of the time, and that could not be changed without extending and refactoring current middleware ATM.

Original key:

Screenshot 2023-06-07 at 16 00 24

With false as the setting:

Screenshot 2023-06-07 at 15 54 31

In our case this allows us to have data of rate limit available to outside systems like Grafana etc, without creating some other, duplicate, data.

The default setting would still be true, otherwise it could be adjusted in any Service Provider (f.e. RouteServiceProvider).

ThrottleRequests::setShouldHashKeys(true);

One thing i'm not sure is whether having a static key based setting is reasonable here. Maybe it could be added somewhere in config/ , but i did not find a reasonable place.

WDYT?

Thanks.

@GrahamCampbell GrahamCampbell changed the title Add shouldHashKeys to ThrottleRequests middleware [10.x] Add shouldHashKeys to ThrottleRequests middleware Jun 8, 2023
@taylorotwell taylorotwell merged commit a22c531 into laravel:10.x Jun 8, 2023
16 checks passed
@DomasWEB
Copy link

Good job, @fosron !

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

Successfully merging this pull request may close these issues.

None yet

3 participants