fix(auth): store mail OTP codes as bcrypt hashes#1803
Conversation
Mail OTP and mail link flows now write a bcrypt hash of the emailed code to the flows table and verify submissions with bcrypt.CompareHashAndPassword. OIDC flows are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesOTP hashing and verification
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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.
🧹 Nitpick comments (1)
core/authenticate/service_test.go (1)
472-476: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLock down legacy-flow rejection.
Add a raw
Nonce: "111111"fixture and assert a matching submitted code returnsErrInvalidMailOTP. The new cases only construct bcrypt hashes, so the stated deployment contract for pre-existing plaintext rows is untested.Also applies to: 590-594
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e6e95930-c6b3-4da6-812c-2e0dee3f84b9
📒 Files selected for processing (2)
core/authenticate/service.gocore/authenticate/service_test.go
Coverage Report for CI Build 30079965546Coverage increased (+0.1%) to 46.866%Details
Uncovered Changes
Coverage Regressions3 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Mail OTP and magic link codes are stored in the flows table as bcrypt hashes instead of the raw string. Verification compares the submitted code against the stored hash.
Changes
core/authenticate/service.go: hash the emailed code before saving the flow; verify withbcrypt.CompareHashAndPassword; OIDC flows unchangedcore/authenticate/service_test.go:TestService_StartFlownow checks the stored hash; newTestService_FinishFlowcovers valid, wrong, and capped attempts; new sequence test covers a wrong attempt followed by the right codeTechnical Details
bcrypt.MinCost.noncecolumn istextand fits the 60-character hash.Test Plan
make lint— 0 issuesmake test— full suite passes🤖 Generated with Claude Code