Create RLS context interceptor (fix SEC-API-4) #351
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 1b - Security Foundations
Problem
RLS policies exist on 23 tables (and will be added to auth tables in #350), but the application NEVER sets the RLS session context. The utility functions in apps/api/src/lib/db-context.ts (withWorkspaceContext, setCurrentUser, etc.) are fully implemented but never called by any service. This is SEC-API-4 from the security review.
Without setting SET LOCAL app.current_user_id, the current_user_id() PostgreSQL function returns NULL, which means all RLS policies silently deny access (or allow it, depending on policy design).
Requirements
Implementation Notes
Files
Acceptance Criteria
Dependencies
Refs #346