Repository navigation
fix(server): count sign-in attempts per client - #217
Open
MustafaYamin wants to merge 2 commits into
Open
MustafaYamin wants to merge 2 commits into
MustafaYamin wants to merge 2 commits into
Conversation
|
Read through the diff and the current helper before reviewing. The switch to the shared limiter is clean, and the test covers exactly the regression: 30 failures from one client 429 that client, a second client with the correct key still gets 200, and DELETE sign-out stays open. A few non-blocking points; the first is the tradeoff worth signing off on:
|
Author
|
Thanks for the review. I checked each point against the code:
|
Author
|
@caspianchan31 Please share what is the update on the PR. |
This branch has not been deployed
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.
Fixes #216
What changed
Sign-in attempts shared one global counter, so anyone who could reach the API could use up the 30 attempts per minute and block the owner's correct key.
POST /api/sessionnow uses the existingrateLimitmiddleware with a limit of 30 attempts per minute per client. The sign-in error message is unchanged, and sign-out (DELETE /api/session) is not limited by it. Access keys must be at least 24 characters, so per-client counting should not materially raise brute-force risk.Verification
tests/rate-limit.test.ts: one client uses up its attempts, a second client signs in with the correct key, and the first client can still sign out. It failed with429before the fix and passes after.pnpm teston Windows 11 with Node 26.12: 518 passed, 3 skipped, 1 failed out of 522. The failure isworker recovery preserves downloads when metadata cannot be inspected, a Windows symlink permission error (EPERM) in a test unrelated to this change.pnpm typecheck,pnpm --dir apps/worker typecheckandpnpm build:serverpass.pnpm lintfails locally on formatting in unchanged files, which still have CRLF line endings in my Windows checkout.build:web,build:iosandbuild:android. No mobile code changed.Integration limits
Clients are only told apart when the server can see their real address. Behind a reverse proxy, without
TRUST_PROXY, all clients may still share one limit.I did not set
TRUST_PROXYinrender.yaml. Community reports suggest Render keeps caller-suppliedX-Forwarded-Forvalues, andresolveClientKeytrusts the first entry, so enabling it there could allow spoofing. I have not verified this on a deployed instance, and a Render-specific fix may need a follow-up.