Notify users when resetting password for an unregistered account (#1251) - #1264
Notify users when resetting password for an unregistered account (#1251)#1264IshanA2007 wants to merge 2 commits into
Conversation
Cognito's hosted UI has prevent_user_existence_errors enabled, so a password reset for an unknown email silently no-ops and the user is left with no feedback. Add a custom /forgot-password/ page that checks the local account table first: - No matching account (case-insensitive email lookup): tell the user to sign in with their UVA email to create one. - Matching account: call Cognito's forgot_password via boto3 to send the reset code, computing SECRET_HASH when the app client has a secret. UserNotFoundException maps to the same "no account" message; other Cognito errors surface a generic retry message. Also add a "Forgot your password?" link to the login modal and unit tests covering GET render, empty/unknown/known email, the no-secret path, UserNotFoundException, and generic Cognito errors (boto3 mocked). Fixes #1251
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 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 |
Closes #1251
Explicitly telling a user "no account exists" partially defeats Cognito's
prevent_user_existence_errors = "ENABLED"(iac/cognito.tf:66) anti-enumeration protection — it lets an attacker probe which emails have accounts. The issue explicitly requests this behavior, and a prior attempt (PR #1254) was closed over exactly this tension. Opening as draft so maintainers can decide whether the UX win is worth the enumeration exposure.Problem
Auth is fully Cognito-hosted. When someone requests a password reset (or email OTP) for an email with no account, Cognito silently no-ops — no email, no message — leaving the user confused.
Fix
New custom
/forgot-password/Django flow:email__iexact).forgot_passwordvia boto3 (computesSECRET_HASHwhen the app client has a secret) to send the reset email; redirects to login with a generic confirmation.UserNotFoundException→ same no-account message; other Cognito errors → generic retry (no existence leak) + logged.Adds a "Forgot your password?" link to the login modal.
Leakage limiting: the success copy is deliberately generic ("If an account exists…") and Cognito-side errors never reveal existence — the only disclosure is the local-DB pre-check the issue asks for.
Verification (actually run — throwaway Postgres)
manage.py check— no issues.tcf_website/tests/test_auth.py— 8/8 pass (GET render, empty/unknown/known email, case-insensitivity, secret-hash on/off,UserNotFoundException, generic error).test_redirects(33 incl. auth) — pass.ruff check— clean.Follow-up
Rate-limit
/forgot-password/(per-IP + per-email) — it's unauthenticated and triggers Cognito calls/emails.🤖 Implemented with Claude Code.