Harden config: no credentials in code (REVIEW SEC-001, SEC-006)

SEC-006: database_url had a working default carrying a real username and
password. Removed. Absence is now reported by 'poorbird check' as a problem
(exit 1) and raised by db.py with a message that names the variable and the
example file, instead of SQLAlchemy's "Could not parse URL from string ''"
three frames down.

SEC-001: enroll_secret stays environment-only and keeps its empty default so
the Phase 1 commands still run on a fresh clone. The device endpoints will
refuse to serve without it when they land.

Both fields now reject unedited placeholders (CHANGE_ME and friends), so a
copied .example cannot boot as though it were configured.

Tests: 12 -> 17. New cases cover the absent default, the readable failure,
and placeholder rejection for both fields.

Note: 6 files unrelated to this change are not clean under 'ruff format'
(the repo is wrapped at 88, pyproject sets line-length 100). Left alone to
keep this diff reviewable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thomas KarnerandClaude Opus 5 committed 2026-09-21 12:11:34 +02:00
1 parent 2188bed633
commit 3344a9e9b1
5 files changed
+125 -17

No files matched your search

+3
View File
@@ -9,6 +9,9 @@
# --- database ---------------------------------------------------------------
# Loopback TCP with scram-sha-256, deliberately not a Unix socket.
# Required: the app has no built-in default and refuses to start without it.
# The literal CHANGE_ME below is rejected at startup, so you cannot copy this
# file and forget to edit it.
POORBIRD_DATABASE_URL=postgresql+psycopg://poorbird:CHANGE_ME@127.0.0.1:5432/poorbird
# --- http -------------------------------------------------------------------