Engineering note · AuraRisk
Removing default credentials and failing fast
- Project
- AuraRisk — Personal project
- Issue
- #15 Remove hardcoded credentials and enforce fail-fast config
- My role
- Author of PR #35
- Stack
- Go · Docker Compose · AWS Secrets Manager
- Status
- Merged 5 Oct 2026
The problem
AuraRisk's docker-compose.yml had development passwords written into it. Postgres used password, and the object store used a fixed access key and secret. The Go backend also had a fallback database URL. If DATABASE_URL was missing, it quietly connected with postgres:password on localhost.
That is convenient on a laptop, but it is the wrong default for a deploy. A missing setting would not stop the service. It would start with credentials anyone can read in the repo. My architecture doc listed this as a launch blocker.
What I did
I made configuration explicit and checked it once, at startup, before anything else runs.
- No fallback DSN. The backend now exits if
DATABASE_URLis not set. - Compose reads from
.env. Credentials come from the repo-root.env, using the${VAR:?message}form so Compose refuses to start when one is missing..env.examplenow useschange-me-*placeholders. - An explicit environment. A new
APP_ENVisdevelopmentby default orproduction. Any other value aborts startup, so a typo cannot skip the production checks. - Production refuses dev values. In production, startup fails if the database password or any other secret is a known dev value or starts with
change-me. It also fails ifEXPO_ACCESS_TOKENis empty while the push notifier is enabled. - All problems at once.
Validate()collects every problem and reports them together, so I don't fix one and restart only to hit the next. - Secret sources. Each secret can be a plain value, a mounted file via
KEY_FILE, or an AWS Secrets Manager reference. Files are resolved first, so AWS credentials can come from a file. The AWS client is only created when a reference is actually present.
A Secrets Manager reference looks like this, with an optional JSON field after the #:
DATABASE_URL=awssm://prod/aurarisk#dsn
EXPO_ACCESS_TOKEN_FILE=/run/secrets/expo_token
Setting both KEY and KEY_FILE is an error, rather than one silently winning.
How I checked it
I added unit tests in config/config_test.go. They cover reading secrets from files, rejecting a value and a file together, resolving Secrets Manager references through a fake fetcher, not creating the fetcher when there are no references, and a missing JSON field. Other tests check that DATABASE_URL is required, that development accepts local credentials, that production rejects them (including key=value DSNs), and that unknown APP_ENV values fail.
I also ran it by hand. The binary exits with a clear error when DATABASE_URL is unset. With APP_ENV=production and the example .env, it lists every dev-credential problem. docker compose config errors when POSTGRES_PASSWORD is missing. go vet and go test pass.
What I learned
A fallback value is a decision made on behalf of a future deploy. For credentials, the safer choice is to stop and explain. Reporting every problem in one message made that strictness much less annoying to live with.
The change also had costs I had to write down. EXPO_ACCESS_TOKEN is now required in production while the notifier runs. Existing local Postgres volumes keep their original password, because Postgres only applies it when the volume is first created. I documented both in the README rather than leaving them to be discovered.