Items deferred from active work. Revisit when time and risk tolerance allow.
Priority: Medium Risk if deferred: High blast radius on credential compromise
Currently all application stacks connect to PostgreSQL as the superuser (POSTGRES_USER). The proper pattern is one dedicated role per application database with only the privileges that application needs.
Proposed approach:
- Add an init script (
02-roles.sh) that creates one role per database:fuelrod_user→ owner offuelroddatabaseshirakalu_user→ owner ofshirakaludatabasesonar_user→ owner ofsonardatabasemetabase_user→ owner ofmetabasedatabase
- Each role gets:
LOGIN,NOSUPERUSER, schema-levelALL PRIVILEGESon its own database only - Each application stack
.envgets its ownDB_USER/DB_PASSWORDpointing at the scoped role - The superuser (
POSTGRES_USER) is used only by pgbouncer and init scripts, never by applications
Why deferred: Requires coordinated credential changes across all application stacks and container image configs. Low risk in a single-tenant self-hosted environment with port 5432 not exposed to the public internet.