
jason.woltjeandClaude Opus 4.6
864c23dc94
feat(#355): Create UserCredential model with RLS and encryption support
Implements secure user credential storage with comprehensive RLS policies
and encryption-ready architecture for Phase 3 of M9-CredentialSecurity.
**Features:**
- UserCredential Prisma model with 19 fields
- CredentialType enum (6 values: API_KEY, OAUTH_TOKEN, etc.)
- CredentialScope enum (USER, WORKSPACE, SYSTEM)
- FORCE ROW LEVEL SECURITY with 3 policies
- Encrypted value storage (OpenBao Transit ready)
- Cascade delete on user/workspace deletion
- Activity logging integration (CREDENTIAL_* actions)
- 28 comprehensive test cases
**Security:**
- RLS owner bypass, user access, workspace admin policies
- SQL injection hardening for is_workspace_admin()
- Encryption version tracking ready
- Full down migration for reversibility
**Testing:**
- 100% enum coverage (all CredentialType + CredentialScope values)
- Unique constraint enforcement
- Foreign key cascade deletes
- Timestamp behavior validation
- JSONB metadata storage
**Files:**
- Migration: 20260207_add_user_credentials (184 lines + 76 line down.sql)
- Security: 20260207163740_fix_sql_injection_is_workspace_admin
- Tests: user-credential.model.spec.ts (28 tests, 544 lines)
- Docs: README.md (228 lines), scratchpad
Fixes #355
Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-07 16:39:15 -06:00
..
2026-02-02 12:51:17 -06:00
2026-02-03 13:45:00 -06:00
2026-02-07 12:49:14 -06:00
2026-02-07 16:39:15 -06:00
2026-02-07 13:16:43 -06:00
2026-01-28 16:06:34 -06:00
2026-01-28 16:06:34 -06:00
2026-01-29 12:29:21 -06:00
2026-01-29 12:29:21 -06:00
2026-01-29 16:07:58 -06:00
2026-01-29 16:13:09 -06:00
2026-01-29 16:13:09 -06:00
2026-01-29 16:59:26 -06:00
2026-01-29 23:26:22 -06:00
2026-01-29 17:58:09 -06:00
2026-01-29 17:58:09 -06:00
2026-01-30 15:19:13 -06:00
2026-01-31 11:57:40 -06:00
2026-02-01 21:01:57 -06:00
2026-02-02 12:30:19 -06:00
2026-02-02 14:25:45 -06:00
2026-02-07 16:39:15 -06:00
2026-01-28 16:06:34 -06:00