Skip to content

feat(db): make the database password optional - #850

Merged
cjorge-thegraph merged 4 commits into
mainfrom
cjorge/connect-without-a-password
Nov 19, 2026
Merged

cjorge-thegraph merged 4 commits into
mainfrom
cjorge/connect-without-a-password

Conversation

@cjorge-thegraph

@cjorge-thegraph cjorge-thegraph commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

db.password was required, so a database that asks the client for no password still needed one in the config, along with a placeholder secret to deliver it. That is the case behind the Cloud SQL Auth Proxy with automatic IAM database authentication (--auto-iam-authn): the proxy's ephemeral certificate carries the identity, and dipper connects to it on localhost with only a username. It is also the case for a local database that trusts its clients.

  • DbConfig.password is now Option<Hidden<String>> with #[serde(default)]. When it's left out, dipper sets no password of its own. The Postgres driver may still take one from PGPASSWORD or ~/.pgpass, and answers a server that asks for one with an empty password. When it's set, nothing changes.
  • k8s/README.md mentions it under the prerequisites.

Running the proxy and granting the identity is the deployment's business, not dipper's; this only lets dipper connect without inventing a password.

Tests:

  • db_config_may_leave_the_password_out failed on main (missing field `password` ) and passes now.
  • it_connects_without_a_password_where_the_server_asks_for_none connects to a pgtemp server, which trusts local connections, and runs SELECT 1. pgtemp is newly a dev-dependency of dipper-service, as it already is of dipper-pgmq and dipper-pgregistry.
  • just fmt-check, just check, just test-unit and dipper-service's it_ tests pass locally.

Changes after review

  • The field's docs and this description no longer claim dipper then sends no password (see above).
  • dipper logs at startup that it connects without a password of its own.
  • When the server refuses the password check (28P01) and db.password is not set, the error says the password was left out. The server's own message ("password authentication failed") doesn't.
  • The test connecting without a password ran against a server that trusts every local client, so it would pass with a password set too. A second test runs a pgtemp server that checks SCRAM passwords over TCP (a custom hba_file). Without the password it fails with the explanation, and with it it gets in.

🤖 Generated with Claude Code

cjorge-thegraph and others added 4 commits November 18, 2026 13:06
`db.password` was required, so a database that asks for none still needed one in the config,
and a placeholder secret to go with it. That is the case behind the Cloud SQL Auth Proxy with
automatic IAM database authentication, where the proxy's identity stands in for a password, and
for a local database that trusts its clients.

`db.password` can now be left out, and dipper then sends none; where it is set, nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review found the change claimed dipper then sends no password, which is not quite so: the
Postgres driver still looks for one in `PGPASSWORD` and `~/.pgpass`, and answers a server that
asks for one with an empty password, which the server reports only as a failed password check.
The field's documentation now says so, dipper logs at startup that it connects without a
password of its own, and a refused password check (28P01) with no `db.password` set says that
the password was left out.

The test connecting without a password ran against a server that trusts every local client,
so it would pass with a password set as well. A second test runs a server that checks SCRAM
passwords over TCP: without the password it fails with the explanation, and with it it gets in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t-a-password

# Conflicts:
#	bin/dipper-service/Cargo.toml
…t-a-password

# Conflicts:
#	bin/dipper-service/src/config.rs
@cjorge-thegraph
cjorge-thegraph marked this pull request as ready for review November 19, 2026 20:14
@cjorge-thegraph
cjorge-thegraph merged commit cb5d3b1 into main Nov 19, 2026
13 checks passed
cjorge-thegraph added a commit that referenced this pull request Nov 19, 2026
…res-and-iisa-at-start

Resolves db.rs against #847 and #850. The startup probe now fails before the pool does, so a
refused password check gets #850's explanation there as well, and the TLS tests, whose stub
drops each connection after its handshake, set a 1s connect wait instead of waiting 120s out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant