fix(dev): bind app Postgres to loopback and fail loud on missing DB secrets (PMS-496) #392

Merged
David merged 4 commits from fix/PMS-496-postgres-loopback-bind-fail-loud-secrets into main 2026-06-28 23:09:42 +02:00
Member

The dev Postgres published its host port at ${MOKOSH_HOST_BIND_IP}:${MOKOSH_PG_HOST_PORT}:5432. just dev derives MOKOSH_HOST_BIND_IP from the first non-loopback interface (br0/eth0), which can be the public edge, so the application database - and the BYPASSRLS mokosh_migrator role reachable through it - was published to the LAN/internet. The DB passwords also silently defaulted to postgres / mokosh_migrator_dev / mokosh_app_dev when unset.

Publish the postgres host port on 127.0.0.1 only. Host-side sqlx-cli (just migrate-run) reaches it via localhost:${MOKOSH_PG_HOST_PORT}; sibling containers use in-network DNS postgres:5432 and need no host publish. MOKOSH_HOST_BIND_IP is no longer used for any host port (it stays for the server BASE_URL). This also keeps the migrator role off every non-loopback interface.

Drop all DB password defaults (MOKOSH_PG_PASSWORD, MOKOSH_MIGRATOR_PASSWORD, MOKOSH_APP_PASSWORD and the postgres:// URLs derived from them) to the ${VAR:?} fail-loud form. just ensure-env (PMS-490) already generates per-host secrets into .env, so an unset value now stops the stack with a helpful message instead of booting with weak credentials.

#PMS-496

The dev Postgres published its host port at ${MOKOSH_HOST_BIND_IP}:${MOKOSH_PG_HOST_PORT}:5432. just dev derives MOKOSH_HOST_BIND_IP from the first non-loopback interface (br0/eth0), which can be the public edge, so the application database - and the BYPASSRLS mokosh_migrator role reachable through it - was published to the LAN/internet. The DB passwords also silently defaulted to postgres / mokosh_migrator_dev / mokosh_app_dev when unset. Publish the postgres host port on 127.0.0.1 only. Host-side sqlx-cli (just migrate-run) reaches it via localhost:${MOKOSH_PG_HOST_PORT}; sibling containers use in-network DNS postgres:5432 and need no host publish. MOKOSH_HOST_BIND_IP is no longer used for any host port (it stays for the server BASE_URL). This also keeps the migrator role off every non-loopback interface. Drop all DB password defaults (MOKOSH_PG_PASSWORD, MOKOSH_MIGRATOR_PASSWORD, MOKOSH_APP_PASSWORD and the postgres:// URLs derived from them) to the ${VAR:?} fail-loud form. just ensure-env (PMS-490) already generates per-host secrets into .env, so an unset value now stops the stack with a helpful message instead of booting with weak credentials. #PMS-496
fix(dev): bind app Postgres to loopback and fail loud on missing DB secrets (PMS-496)
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Successful in 4m22s
E2E / Playwright against staging (pull_request) Failing after 4m31s
Integration / integration tests (pull_request) Successful in 16m18s
300c0abf65
The dev Postgres published its host port at ${MOKOSH_HOST_BIND_IP}:${MOKOSH_PG_HOST_PORT}:5432. just dev derives MOKOSH_HOST_BIND_IP from the first non-loopback interface (br0/eth0), which can be the public edge, so the application database - and the BYPASSRLS mokosh_migrator role reachable through it - was published to the LAN/internet. The DB passwords also silently defaulted to postgres / mokosh_migrator_dev / mokosh_app_dev when unset.

Publish the postgres host port on 127.0.0.1 only. Host-side sqlx-cli (just migrate-run) reaches it via localhost:${MOKOSH_PG_HOST_PORT}; sibling containers use in-network DNS postgres:5432 and need no host publish. MOKOSH_HOST_BIND_IP is no longer used for any host port (it stays for the server BASE_URL). This also keeps the migrator role off every non-loopback interface.

Drop all DB password defaults (MOKOSH_PG_PASSWORD, MOKOSH_MIGRATOR_PASSWORD, MOKOSH_APP_PASSWORD and the postgres:// URLs derived from them) to the ${VAR:?} fail-loud form. just ensure-env (PMS-490) already generates per-host secrets into .env, so an unset value now stops the stack with a helpful message instead of booting with weak credentials.

#PMS-496
Merge remote-tracking branch 'origin/main' into fix/PMS-496-postgres-loopback-bind-fail-loud-secrets
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Successful in 1m50s
E2E / Playwright against staging (pull_request) Failing after 3m20s
Integration / integration tests (pull_request) Successful in 9m0s
9f74f7cdfd
ci: re-trigger E2E against staging (PMS-496)
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Successful in 2m1s
E2E / Playwright against staging (pull_request) Failing after 2m51s
Integration / integration tests (pull_request) Successful in 10m23s
72975a0f6b
#PMS-496
Merge branch 'main' into fix/PMS-496-postgres-loopback-bind-fail-loud-secrets
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 2m59s
Check / fmt + clippy + build + tests (pull_request) Successful in 4m9s
Create release / Gate (release-branch merges only) (pull_request) Successful in 3s
Create release / Create release from merged PR (pull_request) Has been skipped
Integration / integration tests (pull_request) Successful in 13m36s
b9f0cffcea
David merged commit c8f22506cc into main 2026-06-28 23:09:42 +02:00
David deleted branch fix/PMS-496-postgres-loopback-bind-fail-loud-secrets 2026-06-28 23:09:42 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!392
No description provided.