archtechx / tenancy

Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
MIT License
3.67k stars 432 forks source link

RateLimiter stored globally in Redis #1243

Open Lucisu opened 3 months ago

Lucisu commented 3 months ago

Bug description

When using Laravel's RateLimiter, the attempts are stored globally instead of separately per tenant.

Steps to reproduce

Execute in the first tenant:

RateLimiter::attempt( 'key', 100, function () { return true; }, 60*60 );

In the second tenant, you can see that the remaining attempts is 99 instead of 100:

RateLimiter::remaining( 'key', 100 );

Expected behavior

Like the Cache calls, I think that RateLimiter calls should be separated by the tenant.

Laravel version

11.9

stancl/tenancy version

3.8

stancl commented 3 months ago

What bootstrappers do you have enabled?

Lucisu commented 3 months ago

The default ones from 3.8, nothing changed

stancl commented 3 months ago

Does enabling the RedisTenancyBootstrapper fix this?