-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Complete the stub RateLimitService in rate_limit.rs and integrate it as an Axum middleware layer so that individual IP addresses cannot exceed a configurable number of requests per second.
Requirements:
- Complete
RateLimitServiceusing the existinggovernorcrate dependency - Implement
check_rate_limit(ip: &str) -> bool— returnstrueif the request is allowed,falseif rate-limited - Create an Axum middleware
RateLimitLayerthat:- Extracts the client IP from the
X-Forwarded-Forheader (falling back to the connection remote address) - Calls
check_rate_limitfor the IP - Returns
429 Too Many Requestswith aRetry-Afterheader if limited
- Extracts the client IP from the
- Configure rate limits via environment variables:
RATE_LIMIT_PER_SECOND(default: 10)RATE_LIMIT_BURST(default: 20)
- Apply the middleware to all routes except
GET /healthandGET /metrics
Acceptance Criteria:
- Sending more than
RATE_LIMIT_PER_SECONDrequests per second from the same IP returns429 Retry-Afterheader is present on429responses- Health and metrics endpoints are exempt from rate limiting
- Unit tests verify the IP extraction logic and the
429response format
Reactions are currently unavailable