Commit Graph
1 Commits
Author SHA1 Message Date
Cato dcc912e487 fix(auth): an agent's token reads its projects, its account and its conversations (#1677)
A Viewer seat sending its ck_ token got 401 from /api/user-projects, /api/me
and /api/projects/:id, and could not follow a conversation: the middleware
let the Bearer through, but each GET asked for a browser session only.

- GET /api/user-projects, /api/user-projects/:id, /api/me, /api/projects/:id
  resolve the caller with getApiUserId (cookie first, then the token).
- The transcript stream takes a token too (getApiActor); a plain shell stays a
  signed-in person's (mayPeekTab), and the stream stays keyed by the caller.
- Scope is the user's own: owned rows, or a project shared through a
  membership with its role. Writes that change the account or a project stay
  session-only.

Tests: scripts/test/token-session-routes.ts (which handler takes a token,
which does not); scripts/test/token-scope.ts in test:db (a seat's token
reads its shared project read-only, never the owner's other one; expired
and revoked tokens resolve to nobody).
2026-11-12 12:47:24 +01:00