Align authorization and session lifecycle behavior - #2329
Conversation
ReviewLarge, focused security/session-consistency PR. Overall this is high-quality work — the ownership-takeover fix in Potential bug / performance concern (the one I'd most want addressed)
For The codebase already has precedent for worrying about exactly this class of cost — Code quality / maintainability
Security (mostly positive)
Minor
Test coverageTest coverage is a real strength of this PR — |
Review: Align authorization and session lifecycle behavior (#2329)This is a large, security-focused PR and it's executed carefully. I read through the full diff (GraphQL types/mutations, WebSocket auth handshake, chunked-upload worker-token handling, and the frontend document-cache/session isolation work) plus the new/updated test suites. Overall this looks correct, well-tested, and consistent with the repo's permissioning conventions (`BaseService`, `visible_to_user`, `resolve_visible_fk`). Nice work tightening a lot of real IDOR-shaped gaps. Highlights
Minor / non-blocking
Test coverageStrong — the new `test_graphql_resource_contracts.py`, `test_websocket_session_contracts.py`, and `documentCacheSession.test.ts` suites specifically target the classes of bugs this PR fixes (anonymous/cross-user visibility leaks through FKs, ownership preservation on update, worker-token corpus scoping, stream-window vs. expiry timing, cache bleed across auth sessions) rather than just re-testing happy paths. The PR description's test-run summary (1,131-test broad run + full suite passes) is consistent with the scope of the change. Nothing here blocks merging from my read — the one actionable item is the dead-code cleanup (#1 above). |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
ReviewReviewed the full diff (39 files, GraphQL resolvers, WebSocket auth, DRF mutations, chunked-upload/worker-token auth, and frontend document-cache/dev-server hardening). This is a large, well-scoped security-hardening PR and the fixes look correct and are backed by strong regression coverage. Notes below are mostly non-blocking observations. Strengths
Suggestions (non-blocking)
Overall: this reads as a careful, well-tested pass closing several real authorization/session-lifecycle gaps (GraphQL FK leakage, WebSocket permission-revocation lag, upload token-swap, dev-server path traversal, cross-session document cache leakage). Nice work. |
Summary
Align API and browser behavior with the shared authorization and session lifecycle contracts. Apply consistent resource checks and cleanup across related API operations, long-lived sessions, and client state, with regression coverage for normal access and state transitions.
Changes
The GraphQL schema is unchanged and no database migration is required. Document caches are scoped to the current page/session; older incomplete worker uploads without a recorded corpus target may need to be restarted.
Test plan
yarn test:coverage:unit— 2,625 passed across 172 files.yarn tsc --noEmit— passed.yarn lintandyarn any:check:strict— passed.pre-commit run --files <changed files>— passed, including the full backend mypy check.Checklist