Skip to content

[12.x] Add configurable key prefix to ThrottleRequestsWithRedis#59326

Draft
JoshSalway wants to merge 2 commits intolaravel:13.xfrom
JoshSalway:fix/redis-throttle-key-prefix
Draft

[12.x] Add configurable key prefix to ThrottleRequestsWithRedis#59326
JoshSalway wants to merge 2 commits intolaravel:13.xfrom
JoshSalway:fix/redis-throttle-key-prefix

Conversation

@JoshSalway
Copy link
Contributor

Summary

  • Adds a configurable key prefix to ThrottleRequestsWithRedis for Redis ACL compatibility
  • Redis-native rate limiting generates raw, non-namespaced keys (SHA-1 hashes) which break in Redis environments with ACL key pattern restrictions
  • The prefix can be set via setKeyPrefix() or by overriding getKeyPrefix() in a subclass
  • Defaults to empty string for full backward compatibility

Test plan

  • New test verifies key prefix is applied and rate limiting works with prefix
  • New test verifies setKeyPrefix() returns $this for fluent chaining

Fixes #58279

🤖 Generated with Claude Code

@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

JoshSalway and others added 2 commits March 23, 2026 09:47
Redis-native rate limiting via ThrottleRequestsWithRedis generates raw,
non-namespaced Redis keys (e.g., SHA-1 hashes). This breaks in Redis
environments where ACLs restrict access by key pattern (common in
managed Redis/Valkey services).

This adds a configurable key prefix that gets prepended to all Redis
keys used by the throttle middleware. The prefix defaults to empty
string for backward compatibility, but can be set via setKeyPrefix()
or by overriding getKeyPrefix() in a subclass.

Fixes laravel#58279

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that the key prefix is prepended to Redis keys and that
setKeyPrefix() returns the middleware instance for fluent chaining.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JoshSalway JoshSalway force-pushed the fix/redis-throttle-key-prefix branch from 5f565ef to eeba392 Compare March 22, 2026 23:47
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.

Redis-based throttle rate limiting generates non-namespaced keys, breaking Redis ACL compatibility

1 participant