You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Database least privilege: split migration and runtime roles #101
SendDock connects to Postgres as a single role that owns the schema, runs migrations (DDL) and serves runtime traffic (DML). In the bundled Compose stack that role is also the POSTGRES_USER, which the official image makes a superuser of the instance. The database is not published to the host, so the blast radius is contained to the container — but:
Self-hosters connecting to an external or shared Postgres have no guidance for creating a least-privilege role, so they reuse a powerful one.
The runtime process holds DDL rights it never needs after boot.
docker-compose.prod.yml falls back to a well-known default password (senddock) when POSTGRES_PASSWORD is unset.
Proposal
Support two connection strings: DATABASE_URL for runtime (DML only) and an optional MIGRATIONS_DATABASE_URL used by the entrypoint for goose. When the second is unset, behave as today — no breaking change.
Document the recommended role setup for external Postgres: a senddock_migrate owner role and a senddock_app role with SELECT/INSERT/UPDATE/DELETE on the schema and USAGE on sequences, with the exact CREATE ROLE / GRANT statements, and default privileges so future migrations extend grants automatically.
Make the bundled Compose the secure default: create the app role with limited grants in an init script and let the migration step use the owner role.
Require POSTGRES_PASSWORD in docker-compose.prod.yml the way docker-compose.image.yml already does, instead of falling back to a known default.
Acceptance
MIGRATIONS_DATABASE_URL honored by the entrypoint, falling back to DATABASE_URL
Bundled Compose creates separate migrate/app roles by default
prod.yml fails fast without an explicit POSTGRES_PASSWORD
Docs: "Database roles" section under self-hosting configuration with copy-paste SQL for external Postgres
Upgrade note in the changelog confirming existing single-role setups keep working
Activity