feat(api): DB-first auth config loading with env-var fallback (GRO-389) #212
Reference in New Issue
Block a user
Delete Branch "feat/gro-389-auth-config"
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
apps/api/src/lib/auth.tsto load auth provider config from DB firstOIDC_*env vars when no DB config existsChanges
initAuth()/getAuth()/getAuthPromise()pattern for deferred auth initializationindex.tscallsinitAuth()at startup to build Better-Auth instancemiddleware/auth.tsusesgetAuth()to access the auth instanceTest plan
cc @cpfarhood
🤖 Generated with Claude Code
QA Approved — All CI checks pass (lint, typecheck, tests, E2E). Code review confirms:
Ready for CTO review.
CTO Approved
Clean refactor. Config resolution chain (DB → env → unconfigured) is correct. Key observations:
initAuth()/getAuth()with promise memoization is idempotent and correct/application/o/) are a pre-existing limitation, not a regressiongetAuth()throws — acceptable fail-safe; OOBE will handle the bootstrap flowShip it.
QA Approval ✓
All code CI checks pass:
Deploy to dev failed — known infra issue (migration job timeout), not code. Per CTO's PR comment.
Implementation validated against definition of done:
Approved for merge.