- dev auth flow (side-step OAuth) - db event processing integration tests - dev scripts (eg Makefile) - db / test db migration setup scripts.
2.1 KiB
2.1 KiB
Work Summary — 2026-08-03 20:09
Task
Move hardcoded secrets (Auth0 client secret, Etsy API credentials, Postgres DSN) out of source and into environment configuration, as the first step toward a faster local dev/test loop.
Context
Audited the repo for iteration/testing friction. Found no .env/config layer at all — Auth0 client secret, Etsy API keystring/shared secret, and the Postgres connection string (including its password) were literal constants in domains/authentication/auth.go, main.go, and database.go, committed to git. This also blocked adding a dev-only auth bypass cleanly, since authentication.New had no way to accept alternate config.
Changes
- Added
config/config.go: loads.envviagithub.com/joho/godotenv, reads required env vars, fails fast with a clear error naming any that are missing. - Added
.env(gitignored, holds real local values so nothing broke) and.env.example(committed template). .gitignore: added.env.database.go:newPoolnow takesdatabaseURLas a parameter instead of a hardcoded DSN.domains/authentication/auth.go: removed theAUTH0_*constants;authentication.Newnow takesdomain, clientID, clientSecret, callbackURLas parameters;Authenticatorgained adomainfield used byGetLogoutURL.main.go: callsconfig.Load()up front and threads values intonewPool,authentication.New, and the EtsyNewPlatformcall (replacing the hardcodedetsyAPIKeystring/etsyAPISharedSecretconsts).go.mod/go.sum: addedgithub.com/joho/godotenv;go mod tidyalso dropped a few unrelated stale indirect deps.
Verification
go build ./...— clean.go run .— boots against.env, registers all routes identically to before the change.
Follow-ups / not done here
- Secrets are still present in old git history (pre-existing commits) — not rotated or scrubbed. Worth rotating the Auth0 client secret and Etsy credentials at some point since repo history still exposes them.
- Next planned step: add an env-gated dev-only auth bypass (mint a local session without going through real Auth0), now that config is externalized enough to support it cleanly.