Skip to content

fix: consistent case-insensitive email check in GET /projects/:projectId#79

Open
bmersereau wants to merge 5 commits into
willchen96:mainfrom
bmersereau:fix/70-project-access-email-case
Open

fix: consistent case-insensitive email check in GET /projects/:projectId#79
bmersereau wants to merge 5 commits into
willchen96:mainfrom
bmersereau:fix/70-project-access-email-case

Conversation

@bmersereau
Copy link
Copy Markdown

@bmersereau bmersereau commented May 13, 2026

Summary

  • GET /projects/:projectId was using a case-sensitive Array.includes() to check shared_with, while every other access check is case-insensitive; this denied access to legitimate shared users whose stored email had different casing
  • GET /projects list query was using the raw (un-normalized) user email in the shared_with contains filter, also causing missed results for mixed-case emails
  • POST /projects was storing shared_with emails without normalization; PATCH already normalized — now both are consistent
  • Extracted normalizeSharedWith and emailInSharedWith helpers to a new projectAccess.ts module for reuse and testability

Closes #70
Closes #85
Closes #93

Changes

  • backend/src/lib/projectAccess.ts — new normalizeSharedWith and emailInSharedWith helpers
  • backend/src/routes/projects.ts — GET list query uses normalized email; GET access check uses emailInSharedWith; POST normalizes shared_with via normalizeSharedWith
  • backend/src/lib/__tests__/projectEmailNormalization.test.ts — 8 unit tests

Test plan

  • Unit tests: lowercase, dedup, drop empties, case-insensitive lookup, null/undefined email
  • Build and typecheck pass

Dshamir added a commit to Dshamir/AI-Legal that referenced this pull request May 24, 2026
…email

- downloadTokens: pad buffers to equal length before timingSafeEqual
  to eliminate length-oracle side channel (PR willchen96#81)
- keyRotation: add HKDF key derivation with random 16-byte per-row
  salt; existing rows without salt decrypt via legacy SHA-256 path;
  all new encryptions use HKDF (PR willchen96#76)
- projects: use case-insensitive comparison for shared_with email
  in GET /projects/:projectId, matching access.ts pattern (PR willchen96#79)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dshamir added a commit to Dshamir/AI-Legal that referenced this pull request May 24, 2026
…tegration

- CHANGELOG: add security hardening and feature entries for PRs willchen96#158,
  willchen96#81, willchen96#76, willchen96#79, willchen96#145, willchen96#112, willchen96#111, willchen96#110, willchen96#155, willchen96#157, willchen96#59
- ROADMAP: mark 12 new items as completed
- CLAUDE.md: add sanitize.ts, streamTimeout.ts, credits.ts to lib index,
  update test count to 40
- README: update API endpoints table (chat pagination, workflow export),
  security row (HKDF, RLS, prompt defense), encryption row

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment