Add per-IP rate limit to OTP#3999
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesOTP request protection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant sendOtpAction
participant getIPWithSource
participant ratelimit
sendOtpAction->>getIPWithSource: resolve IP and source
getIPWithSource-->>sendOtpAction: return ip and source
sendOtpAction->>ratelimit: check email and applicable IP limits concurrently
ratelimit-->>sendOtpAction: return limit results
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Overall I think this is a great system protection to add (esp. against bots / AI), however would recommend adding a little better logging/observability so we can understand how often we're using FALLBACK_IP_ADDRESS and denying OTP requests.
Also, it would be good to setup some sort of alarming on OTP throttling so we can understand if we are getting attacked vs. many new signups for a new corp client etc. Maybe >10 blocks in 10m to start
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/lib/actions/send-otp.ts`:
- Around line 43-50: Update the email-based limiter in the Promise.all block to
use only the email address in its send-otp key, restoring the
`send-otp:${email}` format. Keep the separate IP limiter keyed by
`send-otp:${ip}` and preserve the existing fallback behavior for unknown IPs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1a403687-cc4c-40ba-96a1-e80f78d16b2f
📒 Files selected for processing (2)
apps/web/lib/actions/send-otp.tsapps/web/lib/api/utils/get-ip.ts
Summary by CodeRabbit
Bug Fixes