Commit Graph

16 Commits

Author SHA1 Message Date
7287f10c9a feat: migrate Nessa auth to Clerk session tokens (task 03)
- src/server/nessa-auth.ts: replace jose HS256 sign/verify with Clerk
  session JWT verification via @clerk/backend verifyToken (RS256/JWKS).
  signNessaToken removed — frontend now supplies Clerk session tokens.
- src/server/api/utils.ts: createTRPCContext verifies Clerk JWT, resolves
  ctx.nessaUserId via SELECT id FROM users WHERE clerkUserId=? on the
  shared NessaConnectionFactory. Lookup miss throws typed UNAUTHORIZED
  (webhook has not run yet). Invalid/expired tokens are swallowed; the
  enforceNessaUser middleware rejects null nessaUserId.
- src/server/api/routers/nessa-community-authz.test.ts: add clerkUserId
  lookup tests (seeded match, missing row, mismatched id, local≠clerk).
- src/server/nessa-auth.test.ts: verifyNessaToken unit tests with mocked
  @clerk/backend (valid sub, missing sub, malformed/expired/wrong-signature
  rejection) plus static audit that signNessaToken is gone.
- src/server/clerk-user-webhook.ts + src/routes/api/clerk-webhook.ts:
  Clerk user.created/user.updated webhook handler (Svix signature
  verification, idempotent upsert by clerkUserId, lazy ALTER TABLE
  migration) with full test suite.
- src/server/api/routers/nessa.ts: remove legacy register/login/google/
  apple sign-in mutations (Clerk is now the sole identity provider).
- src/env/server.ts: add NESSA_CLERK_SECRET, NESSA_CLERK_JWT_ISSUER,
  NESSA_CLERK_WEBHOOK_SECRET; NESSA_JWT_SECRET moved to optional.
- package.json: add @clerk/backend, svix; lineage/auth.test.ts and
  nessa-ownership.test.ts: add Clerk env vars to env mocks.
- .env.example: document Clerk config vars and rotation.
- delete nessa-google-oauth.test.ts (Google auth removed).

ctx.nessaUserId remains the local users.id — router bodies are untouched.
2026-07-23 01:40:53 -04:00
3bb3e80b77 security: lock down public S3 procedures and sanitize keys (p8-001, p8-008)
- Convert simpleDeleteImage, deleteImage, getPreSignedURL, listAttachments
  from publicProcedure to csrfProtectedProcedure
- Add S3 type allowlist validation to prevent path traversal
- Sanitize title/filename inputs for S3 key construction
- Add ownership checks on delete operations
- Remove hashPassword/checkPassword procedures (bcrypt internals)
- Add regression tests for sanitization and validation

Fixes: p8-001 (anonymous S3 deletion), p8-008 (public presigned URL with unsanitized type)
2026-07-22 17:37:58 -04:00
d7c91ac6c5 rename 2026-01-24 19:31:14 -05:00
955c856a85 fix: analytics and deprecated warning 2026-01-21 13:58:34 -05:00
58d48dac70 checkpoint 2026-01-21 12:22:19 -05:00
5fc082178c cairn work 2026-01-21 01:56:54 -05:00
f68f1f462a session state simplification 2026-01-12 09:24:58 -05:00
9fc0a73fea general: hot path cooldown 2026-01-11 14:24:28 -05:00
0a0c0e313e migrated 2026-01-07 16:22:31 -05:00
ea556b3677 fledged out analytics, self gather, remove vercel speed insights 2026-01-06 01:34:55 -05:00
d2ee61b830 analytics page 2026-01-06 00:40:44 -05:00
7e89e6dda2 removed excess comments 2026-01-04 11:14:54 -05:00
8ca8e6f712 remove excess comments 2025-12-23 10:30:51 -05:00
79d2055159 okok 2025-12-19 17:15:05 -05:00
b3df3eedd2 continued migration 2025-12-16 23:31:12 -05:00
8fb748f401 init 2025-12-16 22:42:05 -05:00