Skip to content

fix: apply authLimiter to OTP and password reset routes#264

Merged
yash-pouranik merged 2 commits into
geturbackend:mainfrom
shravya290706:fix-auth-rate-limiter
Jun 2, 2026
Merged

fix: apply authLimiter to OTP and password reset routes#264
yash-pouranik merged 2 commits into
geturbackend:mainfrom
shravya290706:fix-auth-rate-limiter

Conversation

@shravya290706
Copy link
Copy Markdown
Contributor

@shravya290706 shravya290706 commented Jun 2, 2026

Summary

This PR applies authLimiter to OTP and password reset endpoints that were previously protected only by dashboardLimiter.

Changes Made

  • Added authLimiter to:

    • /send-otp
    • /verify-otp
    • /forgot-password
    • /reset-password

Why

These endpoints were inheriting dashboardLimiter (1000 requests / 15 min), making them vulnerable to:

  • OTP brute-force attempts
  • OTP email spam
  • Password reset abuse
  • User enumeration attacks

Applying authLimiter aligns them with the same protection already used for login and registration endpoints.

Fixes #246

Summary by CodeRabbit

  • Bug Fixes
    • Applied rate limiting to sensitive authentication endpoints including OTP sending and verification, password recovery requests, and password reset operations to prevent abuse and enhance system stability and security against unauthorized access attempts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Warning

Review limit reached

@shravya290706, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 57 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07e57e23-555f-4791-bce3-54b8e22ba4e4

📥 Commits

Reviewing files that changed from the base of the PR and between e59c716 and 7a10958.

📒 Files selected for processing (1)
  • apps/dashboard-api/src/routes/auth.js
📝 Walkthrough

Walkthrough

The PR applies the strict authLimiter middleware to four authentication endpoints—/send-otp, /verify-otp, /forgot-password, and /reset-password—preventing them from inheriting the permissive global dashboardLimiter. This limits these sensitive endpoints to 10 requests per 15 minutes instead of 1000, closing brute-force and enumeration attack vectors.

Changes

Auth endpoint rate limiting

Layer / File(s) Summary
Auth endpoint rate limiting
apps/dashboard-api/src/routes/auth.js
The /send-otp, /verify-otp, /forgot-password, and /reset-password route definitions are updated to explicitly chain authLimiter middleware, protecting these sensitive endpoints from brute-force and enumeration attacks by enforcing the strict 10-request-per-15-minute limit.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

Possibly related PRs

  • geturbackend/urBackend#33: Establishes the pattern of protecting login and register endpoints with authLimiter; this PR extends that same rate-limit protection to OTP and password-recovery endpoints.

Poem

🐰 A rabbit hops to guard the gate,
With timers firm to rate-limit fate,
Ten tries per fifteen—a fortress wall,
No brute-force beast shall breach at all! 🔒

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: applying authLimiter middleware to OTP and password reset routes.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #246: authLimiter is applied to all four specified endpoints (send-otp, verify-otp, forgot-password, reset-password).
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue #246. Only the four specified OTP and password-recovery routes were modified; no unrelated changes were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/dashboard-api/src/routes/auth.js`:
- Around line 43-47: The four routes using authLimiter (router.post('/send-otp',
authLimiter, sendOtp); router.post('/verify-otp', authLimiter, verifyOtp);
router.post('/forgot-password', authLimiter, forgotPassword);
router.post('/reset-password', authLimiter, resetPassword);) are currently
registered after router.use(dashboardLimiter) and thus inherit dashboardLimiter
in addition to authLimiter; move these four router.post registrations up so they
are placed alongside the existing /register and /login routes (before the
router.use(dashboardLimiter) call) so only authLimiter is applied and the
dashboardLimiter state is not unnecessarily tracked for these endpoints.
🪄 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: bab88a21-50dc-4571-af39-55d4e1e07041

📥 Commits

Reviewing files that changed from the base of the PR and between ed66a6c and e59c716.

📒 Files selected for processing (1)
  • apps/dashboard-api/src/routes/auth.js

Comment thread apps/dashboard-api/src/routes/auth.js Outdated
@yash-pouranik yash-pouranik merged commit 52ead55 into geturbackend:main Jun 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants