Feature/auth rate limiting#144
Conversation
|
@MohitBareja16 is attempting to deploy a commit to the Sameer's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @MohitBareja16! Thank you for the contribution. Adding CAPTCHA verification to the Send OTP and Forgot Password routes is a great security addition. However, there is a major technical blocker: this PR contains a version of the backend that is severely outdated. We have recently merged Dual-Token Auth, Multi-tab support, Swagger Docs, and Message Ticks. Your current PR would accidentally delete/revert all of those features. Please rebase your branch on the latest 'main' one last time. You should focus strictly on:
We really want this security layer, but it must be applied to the current version of the project! |
Description
This PR patches a critical security vulnerability where the authentication endpoints were unprotected against bot spam and automated attacks. Specifically, this implements the missing
sendOTPandforgotPasswordcontrollers while ensuring that all entry points rigorously validate acaptchaTokenbefore proceeding.🛡️ Security & Authentication Updates
verifyRecaptchaUtility: Added a secure server-side utility inbackend/lib/utils.jsthat integrates with Google's reCAPTCHA API (/recaptcha/api/siteverify) to validate incomingcaptchaTokens.sendOTPEndpoint: Built the/api/v1/auth/send-otpcontroller with strict CAPTCHA verification to prevent automated scripts from bypassing limits and exhausting our email service (Nodemailer) quotas.forgotPasswordEndpoint: Built the/api/v1/auth/forgot-passwordcontroller, securing the password reset flow from malicious spam requests.loginandsignupcontrollers to strictly extract and validate thecaptchaToken. All invalid requests are now immediately rejected with a403 Forbiddenresponse.🚏 Routing Updates
POST /send-otpandPOST /forgot-passwordinbackend/routes/user.routes.js.Impact
Testing
captchaTokenare rejected with a400 Bad Request.captchaTokenare blocked with a403 Forbidden.