Skip to content

Replace thamtech/yii2-ratelimiter-advanced with built-in IP rate limiter#18510

Open
timkelty wants to merge 11 commits into4.xfrom
drop-thamtech-ratelimiter
Open

Replace thamtech/yii2-ratelimiter-advanced with built-in IP rate limiter#18510
timkelty wants to merge 11 commits into4.xfrom
drop-thamtech-ratelimiter

Conversation

@timkelty
Copy link
Contributor

@timkelty timkelty commented Mar 4, 2026

thamtech/yii2-ratelimiter-advanced is outdated and breaks with cache components defined as functions or that don't extend yii/caching/Cache. So, this PR:

  • Removes the thamtech/yii2-ratelimiter-advanced dependency, in favor of Yii's built-in RateLimiter.
  • Adds craft\filters\IpRateLimitIdentity to extend IP-based rate limiting to Yii's RateLimiter.

This is intended as lateral change - the rate limiting behavior for send-password-reset-email remains equivalent.

@timkelty timkelty requested a review from brandonkelly March 4, 2026 03:36
@timkelty timkelty marked this pull request as ready for review March 4, 2026 03:36
@timkelty timkelty force-pushed the drop-thamtech-ratelimiter branch from 43daf3b to 19f8f9e Compare March 4, 2026 03:38
timkelty and others added 9 commits March 4, 2026 06:28
Introduces `craft\filters\RateLimiter` and `craft\filters\IpRateLimitIdentity`
to provide IP-based rate limiting for unauthenticated requests, removing the
external dependency while maintaining equivalent behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use idiomatic Yii2 config array pattern
- Remove unused import
- Fix code style (explicit property declarations)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The custom craft\filters\RateLimiter was just a thin wrapper setting defaults
and wiring up the user closure. Since Yii's RateLimiter natively supports a
Closure for the user property, configure it inline in UsersController instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass Request instance instead of null to satisfy parameter types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PHPStan flags this as unused at level 5.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@timkelty timkelty force-pushed the drop-thamtech-ratelimiter branch from c586aea to 5aa4db3 Compare March 4, 2026 11:30
@timkelty timkelty changed the base branch from 5.x to 4.x March 4, 2026 11:30
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.

1 participant