Change request saved in this viewer
This review has no pull request, so the decision stays in this viewer.
An agent sees the decision only while it watches this review. If the agent is not answering in chat, ask it there: Continue the mcp-review at /demo
Snapshot #2 of 2
Harden sign-in: hashed passwords, expiring sessions and per-session rate limits
Sign-in no longer accepts any password, and a session no longer lives forever.
What changes
- Passwords are hashed with scrypt and a per-user salt. The md5 helpers and the legacy token module are deleted.
- A session expires 12 hours after it starts, and its token rotates on use.
- Each session gets a token bucket for requests, stored in Postgres, so a restart does not reset it.
- The HTTP layer becomes an explicit middleware chain with CORS, request IDs and an event stream.
flowchart LR
Login[login] --> Session[session]
Session --> Router[api/router]
Config[config.port] --> Server[listen 8080]
How to review
Start with Core auth changes and Session store. The scheduled jobs only change their logger import, so that section shows two examples and keeps the other jobs in one group.
Coverage
- Presentation
- All 143 selected changes are placed. 132 in groups · 0 unbucketed · 4 generated · 7 without a text diff
- Explanations
- 13 of 13 groups have an explanation.
- Agent analysis
- Reading the analysis status…
- Human review
- 7 of 136 hunks are marked reviewed.
Outdated discussions 1
These discussions have no verified location in the displayed changes. Each keeps its original code and stays open to replies and resolution.
OPEN src/auth.ts Outdated · Ln 27 This token is the user name and the time of the request, so anyone who knows roughly when a user refreshed can guess it. Should it be random, like the session I…
The selected new-side lines no longer exist in src/auth.ts.
session.token = `tok-${session.user}-${Date.now()}`;
Sections
Each section opens on its own page, so the browser loads only the changes of that section. Show all sections on one page
-
2 files · 4 hunks · +45 -3 · 0/2 files reviewed · 0 open discussions
Login validates credentials before it issues a token, and the bearer middleware resolves the session for every other route. A refreshed token is random, so nobody can derive it from the user name and the time of the request.
Why it matters
- Empty credentials previously received tokens.
- A token that the clock decides is guessable.
src/auth.tsand the auth middleware also appear in other sections. This section shows only the hunks of this change.
sequenceDiagram participant C as Client participant A as auth.login C->>A: user, password alt missing A-->>C: throw else ok A-->>C: token end -
3 files · 4 hunks · +34 -219 · 0/3 files reviewed · 0 open discussions
scrypt with a per-user salt replaces the placeholder hash, and token minting moves into
lib/crypto.ts.src/auth.tsshows up here as well as under Core auth changes — this section owns only itshashPasswordhunk, so each section shows the diff it is actually about. -
6 files · 10 hunks · +85 -192 · 1/6 files reviewed · 0 open discussions
Session creation requires a user, expiry uses
createdAt, rotation happens on use, and the browser hook keeps the token fresh.The session SQL lives in
src/db/queries.ts, whose remaining hunks belong to Database & migrations. -
16 files · 26 hunks · +817 -330 · 0/16 files reviewed · 0 open discussions
Router attaches sessions on login, handlers tighten JSON parsing and add an error boundary, and the server grows a middleware chain plus an SSE stream.
flowchart TB R[router] --> H[handlers] R --> S[session] R --> E[sse] -
5 files · 7 hunks · +74 -207 · 0/5 files reviewed · 0 open discussions
A token bucket per session (falling back to the remote address), persisted so a restart does not hand out a fresh budget.
The
raised retriesnote insrc/config.tsbelongs to this change, while the port andloadConfighunks in the same file sit under Config / glue. -
8 files · 12 hunks · +195 -78 · 0/8 files reviewed · 0 open discussions
Pool sizing and transactions, the sessions/audit tables, and the queries behind auditing and expiry.
-
2 files · 3 hunks · +31 -6 · 2/2 files reviewed · 0 open discussions
Default port moves 3000 → 8080,
loadConfigreads env overrides, andlib/env.tsparses them with explicit defaults. -
11 files · 12 hunks · +348 -129 · 0/11 files reviewed · 0 open discussions
Login form with local validation, a session badge, a toast, and the styles for all three.
-
8 files · 12 hunks · +111 -130 · 0/8 files reviewed · 0 open discussions
Formatting helpers normalize users, logging becomes structured, and retries get jittered backoff.
-
9 files · 13 hunks · +158 -183 · 0/9 files reviewed · 0 open discussions
Sign-in flow, endpoint table, error codes, rate-limit budgets, changelog.
-
6 files · 7 hunks · +139 -13 · 0/6 files reviewed · 0 open discussions
Node 24, pnpm, a lint/typecheck/test pipeline, an e2e job, and a slimmer image.
-
6 files · 6 hunks · +18 -18 · 0/6 files reviewed · 0 open discussions
Mechanical change · 2 example files · 4 remaining matching files
Every scheduled job moves from the old
loggermodule to the structuredlogmodule. The two examples show the whole change; the other jobs repeat it exactly. -
13 files · 16 hunks · +292 -169 · 0/13 files reviewed · 0 open discussions
The tests of the production sections above, in the same order: login and hashing, sessions, the HTTP API, rate limiting and the database queries, then the end-to-end passes over the form and the retired fakes.
-
7 files · 0 hunks · +0 -0 · 0/0 files reviewed · 0 open discussions
Selected files that have no text hunks, such as binary, renamed, or unavailable sources. Each file stays in the review with its reason.
-
4 files · 4 hunks · +1269 -98 · 0/4 files reviewed · 0 open discussions
Lockfiles, codegen, and vendored files. Diffs load on demand, no syntax highlighting until asked.