Summary
- Add GATEKEEPER_RATE_LIMIT_BYPASS_IPS (comma-separated) and GATEKEEPER_RATE_LIMIT_BYPASS_KEY (checked via x-ratelimit-bypass header) env vars to exempt specific requests from rate limiting
- Replace tower_governor with custom middleware using the governor crate directly, since tower_governor has no built-in bypass mechanism
- All 4 rate-limited routes (sign-in, createSession, createAccount, gate/signup) use the new middleware
Motivation
Certain trusted IPs (e.g. the PDS itself at 148.251.49.115) were being rate-limited, producing "Rate limit exceeded for smart IP" log noise. The PDS already supports PDS_RATE_LIMIT_BYPASS_KEY and PDS_RATE_LIMIT_BYPASS_IPS โ this brings the same pattern to gatekeeper.
Test plan
- 11 new unit tests in src/rate_limit.rs covering IP extraction, bypass by IP, bypass by token, unconfigured default, env parsing, 429 enforcement, and bypass passthrough
- All 37 tests pass (cargo test)
- Manual smoke test: hit a rate-limited endpoint with/without bypass header/IP
BTW this was vibe coded, IDK Rust...