Skip to content

feat(gateway): enforce per-key rateLimitPerMinute under the tier ceiling - #1549

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
EmannuellaO:feat/per-key-rate-limit
Oct 24, 2026
Merged

greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
EmannuellaO:feat/per-key-rate-limit

Conversation

@EmannuellaO

Copy link
Copy Markdown
Contributor

Closes #1505

Summary

  • Enforce per-key rate limiting in gateway limiter using key bucket with effective limit = min(rateLimitPerMinute, tier ceiling). Keys only narrow.
  • Add store-backed per-key limiting via checkKeyLimit with safe tier resolution (hasOwnProperty/known tier set, reject prototype keys).
  • Return effectiveRateLimitPerMinute in key creation/list responses and validate unknown tiers on create (400).
  • Add truthful RateLimit headers on 429 reflecting the stricter bucket.
  • Add tests for per-key limiting and tier hardening.

Headers: when both user and key buckets apply, headers advertise the bucket closer to exhaustion (stricter one). On 429, headers describe the bucket that caused the rejection.

Closes CalloraOrg#1505

Co-authored-by: EmmanuellaO <emmanuella@example.com>
@greatest0fallt1me
greatest0fallt1me merged commit eacc5ca into CalloraOrg:main Oct 24, 2026
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.

Enforce each API key's rateLimitPerMinute in the gateway limiter instead of only labelling metrics with it

3 participants