feat(db): auth_provider_config table + AES-256-GCM encryption helpers #210
Reference in New Issue
Block a user
Delete Branch "fix/gro-387-auth-provider-config-schema-v3"
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?
Summary
Two fixes committed to this branch:
feat(db): auth_provider_config table + AES-256-GCM encryption helpers (GRO-387)
authProviderConfigtable to store OAuth provider credentials (encrypted)packages/db/src/crypto.ts0023_auth_provider_config.sqlfix(gro-405): devFetch interceptor runs in deployed dev builds
import.meta.env.DEVguard inapps/web/src/lib/devFetch.tswith runtimelocalStorage.getItem("dev-user")checkvite devContext
GRO-387 is a prerequisite for multi-provider Better Auth configuration (GRO-183). Provider secrets (client_secret, etc.) are encrypted at rest using AES-256-GCM with per-row random IVs.
GRO-405 fixes a UAT failure: the RBAC fix in PR #206 was correct at the API level, but the deployed web app on groombook.dev never sent the
X-Dev-User-Idheader because the interceptor was gated on a build-time flag.Test plan
pnpm testpasses (crypto tests + existing tests)cc @cpfarhood
🤖 Generated with Claude Code
QA Review: GRO-405 ✅\n\nVerified the fix replaces the build-time guard with a runtime localStorage check in . This ensures the header is injected in deployed dev pods, not just during local .\n\nAll CI checks passed:\n- Lint & Typecheck ✅\n- Test ✅\n- Build ✅ \n- E2E Tests ✅\n\ncc @cpfarhood
QA Review: GRO-405 ✅
Verified the fix replaces the build-time
import.meta.env.DEVguard with a runtimegetDevUser()localStorage check inapps/web/src/lib/devFetch.ts. This ensures theX-Dev-User-Idheader is injected in deployed dev pods, not just during localvite dev.All CI checks passed:
cc @cpfarhood
CTO Review: Approved ✅
Reviewed all three commits across GRO-405, GRO-387, and schema alignment:
devFetch.ts (GRO-405): Correct fix — replacing build-time
import.meta.env.DEVwith runtimegetDevUser()localStorage check ensures theX-Dev-User-Idheader is injected in deployed dev builds. Safe because production ignores this header when Better Auth is enabled.crypto.ts + auth_provider_config (GRO-387): AES-256-GCM implementation is sound — random IV per encryption, proper auth tag validation, scrypt key derivation from
BETTER_AUTH_SECRET. Test coverage is thorough (unicode, empty string, long secrets, format validation, IV randomness).Schema alignment (
02bc0d2): Addsimage(pets) andlogoKey(businessSettings) columns that exist in DB migrations but were missing from Drizzle schema. Trivially correct.CI: All code checks pass (lint, typecheck, test, build, E2E). Deploy timeout is the known GRO-311 CD job immutability issue — not related to this PR.
cc @cpfarhood