Repository navigation
fix(auth): enforce install-wide login attempt rate limiting across servers - #1199
Merged
Merged
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
This was referenced Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Install-wide login attempt rate limiting across main API, KDS, and Server App for FloCafe issue #1181
What Changed
main/middleware/security.tswith a sharedloginAuthRateLimitsingleton and install-wide failed-login lockout tracking (checkLoginRateLimit,incrementFailedLogin,resetSuccessfulLogin) keyed to canonical client IPs./api/auth/loginacross the Main API (main/routes/auth.ts), KDS (main/kds-server.ts), and Server App (main/server-app.ts) to enforce the shared 5-attempt failure limit and 15-minute lockout, return remaining attempt counts on bad credentials, and reset failures on successful login.tests/cross-server-login-rate-limits.test.ts(registered inpackage.json) and updated authentication and API documentation.Risk Assessment
✅ Low: The change straightforwardly consolidates login attempt rate limiting into shared middleware across all three local HTTP servers with thorough regression test coverage.
Testing
Stood up FloCafe's three HTTP listeners (Main API, Standalone KDS, and Server App) backed by an isolated SQLite database, exercised all 6 cross-server authentication and rate-limiting scenarios end-to-end with live HTTP requests and cURL invocations, verified the targeted regression test suite passes, and captured full request/response transcripts into the evidence directory. No visual/UI artifacts were captured because this change modifies only backend Express authentication endpoints and security middleware with no frontend/UI changes.
Evidence: Live cURL Session Transcript
=== FloCafe Live cURL Session Transcript === Generated on: Sat Oct 17 08:07:04 UTC 2026 Targets: Main API (:3001), KDS (:3002), Server App (:3003) Attempt 1 on Main API (:3001) - Bad password: HTTP/1.1 401 Unauthorized {"error":"Invalid credentials","attempts_remaining":4} Attempt 2 on KDS (:3002) - Bad password: HTTP/1.1 401 Unauthorized {"error":"Invalid credentials","attempts_remaining":3} Attempt 3 on Server App (:3003) - Bad password: HTTP/1.1 401 Unauthorized {"error":"Invalid credentials","attempts_remaining":2} Attempt 4 on Main API (:3001) - Bad password: HTTP/1.1 401 Unauthorized {"error":"Invalid credentials","attempts_remaining":1} Attempt 5 on KDS (:3002) - Bad password (triggers 15m lockout): HTTP/1.1 401 Unauthorized {"error":"Invalid credentials","attempts_remaining":0,"lockout_minutes":15} Attempt 6 on Server App (:3003) - Rejected with HTTP 429: HTTP/1.1 429 Too Many Requests {"error":"Too many failed attempts. Try again in 15 minutes."} Attempt 7 on Main API (:3001) - Valid credentials rejected during lockout (429): HTTP/1.1 429 Too Many Requests {"error":"Too many failed attempts. Try again in 15 minutes."}Evidence: Live Verification Markdown Report
~/.no-mistakes/evidence/01M54DJ9SY58Q324K9D2KX9QAZ/cross-server-login-live-requests.json)Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
main/middleware/security.ts:123- The change introduces an unrequested scope option and dispatch branch to authRateLimit (main/middleware/security.ts:123-126). All default login endpoints across :3001, :3002, and :3003 call loginAuthRateLimit() directly, and no caller passes scope: 'login'. Recommend removing scope?: 'login' and the conditional branch to keep authRateLimit minimal.main/middleware/security.ts:120- The change introduces resetSharedAuthRateLimiter as an exported alias of resetSharedLoginAuthRateLimiter (main/middleware/security.ts:120). No requirement in the user intent needs this secondary alias, and neither identifier is referenced across callers or tests. Recommend removing the alias resetSharedAuthRateLimiter.main/routes/auth.ts:200- In main/routes/auth.ts:200, const checkRateLimit = checkLoginRateLimit; defines an unnecessary local alias. Sibling call sites in main/kds-server.ts:244 and main/server-app.ts:274 invoke checkLoginRateLimit(ip) directly. Recommend removing the alias at line 200 and invoking checkLoginRateLimit(ip) directly at line 240.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run test:cross-server-login-rate-limitsnode tests/run-electron-node-test.cjs tests/cross-server-login-rate-limits.test.tsLive multi-server driver (POST /api/auth/login across Main API, KDS, Server App)curl -i -s -X POST http://127.0.0.1:3001/api/auth/logincurl -i -s -X POST http://127.0.0.1:3002/api/auth/logincurl -i -s -X POST http://127.0.0.1:3003/api/auth/login✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.