feat(throttle): admin-managed rate limits, org overrides and API consumer metrics - #281
Merged
Merged
Conversation
…y IP ThrottleRequests runs before API authentication, so Laravel's default signature always fell back to route domain + client IP. Behind a load balancer that IP is the balancer's, and no route has a domain, so every tenant, API key and console visitor shared one bucket: one busy integration returned 429 to the whole platform. Key the limiter on the hashed credential (API key, Sanctum token, basic auth), falling back to the user and then the IP only when none is sent, and scope it by first path segment so /v1 and /int stay separate. Also keep Retry-After and X-RateLimit-* on the 429 response so throttled clients know when to retry.
…umer metrics - ApiRateLimits: effective limits from env defaults plus a system.rate-limits setting an admin can change at runtime; per-organization overrides (custom limit or unlimited); credential -> organization lookup cached per key. - ApiConsumerMetrics: per-consumer request and 429 counts in Redis (minute buckets for 2h, hour buckets for 8 days), recorded by the throttle middleware so throttled requests are visible too. - RateLimitController + int/v1/rate-limits routes (admin only): get/save/reset settings, top consumers by window, clear a consumer's limiter window. - ThrottleRequests applies overrides and records every request.
Merged
roncodes
changed the base branch from
fix/per-consumer-throttle
to
release/v1.6.66
September 29, 2026 08:27
roncodes
force-pushed
the
release/v1.6.66
branch
from
September 29, 2026 08:28
f4fc81a to
2f008a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #280 (per-consumer throttle keying). Merge that first; this PR then retargets to
main.What
ApiRateLimits: the effective rate-limit settings.THROTTLE_*) supplies the defaults. A system admin can override them at runtime; the override is stored assystem.rate-limits, cached, and cleared on save.flb_test_sandbox, and$secrets, which are retried on sandbox)ApiConsumerMetrics: per-consumer request and 429 counts.api_request_logsonly records writes and never sees a 429.ThrottleRequestsapplies the settings and overrides, and records every request, including throttled ones and those that bypass throttling.RateLimitController(behindAdminRequest), underint/v1/rate-limits:GET/POST/DELETE settingsGET consumers?window=&sort=&limit=POST consumers/{signature}/reset, which clears one consumer's limiter windowTHROTTLE_TRACK_CONSUMERS(default true) andTHROTTLE_METRICS_REDIS_CONNECTION(defaultcache).The console UI is in the companion fleetbase/fleetbase PR.
Tests
test:lintandtest:date-driftare clean.