Repository navigation
fix(init): read the admin variables alike on every backend - #1349
Conversation
On Cassandra, init with EXTENDDB_ADMIN_PASSWORD set and EXTENDDB_ADMIN_USER not set printed the supplied password on stdout, in its "shown once" credentials box. The Cassandra bootstrapper took the password as from the environment only when both variables were set. Otherwise it returned the password as a generated one. It now takes the password as from the environment whenever one is supplied, as the other backends do, and returns no password. On MongoDB and Cassandra, init took an empty EXTENDDB_ADMIN_USER or EXTENDDB_ADMIN_PASSWORD as the admin name or the password. SQLite and PostgreSQL treated an empty value as unset, each in its own bootstrapper. write_bootstrap_rows now passes an empty value on as no value for every backend, and the copies in the SQLite and PostgreSQL bootstrappers are gone. The SQLite server with an in-memory database or a dev build keeps its own check, because it writes its admin at start without write_bootstrap_rows. The Cassandra test of an init that finishes a stopped one now supplies a password without a user name. It fails on the Cassandra code before this change. A SQLite test runs write_bootstrap_rows over four pairs of the two values, and it fails without the shared check. The Cassandra image README no longer says that init prints a supplied password. The upgrade manual has a v1.1.0 entry for catalogs that an earlier release initialized with an empty password. Closes #1339
…ert message The assert message of the admin variables test printed the password of its row, and code scanning reported it as cleartext logging of a password. The message now gives the row number. Refs #1339
|
|
||
| **What changed.** `extenddb init` takes an empty `EXTENDDB_ADMIN_USER` or `EXTENDDB_ADMIN_PASSWORD` as unset on every backend: it names the admin `admin`, or generates a password. On MongoDB and Cassandra, 1.0.0 took the empty string as the name or the password. On Cassandra, `init` with `EXTENDDB_ADMIN_PASSWORD` set and `EXTENDDB_ADMIN_USER` not set no longer prints the supplied password (#1339). | ||
|
|
||
| **Who is affected.** A MongoDB or Cassandra catalog that an earlier release initialized with an empty `EXTENDDB_ADMIN_PASSWORD` keeps an admin whose password is empty. Give it a password with `extenddb manage change-admin-password`, with `EXTENDDB_PASSWORD` set to an empty value for the login. The output of a Cassandra `init` from an earlier release with only `EXTENDDB_ADMIN_PASSWORD` set holds that password, so change it if that output was kept. No catalog migration is required. |
There was a problem hiding this comment.
Update: Lee's backend runs show this holds for MongoDB but not Cassandra, which rejects the empty key before creating an admin. The upgrade note now documents the two backend-specific cases.
There was a problem hiding this comment.
Thanks LJMart11. This holds for MongoDB, and Cassandra turned out different. I ran init with EXTENDDB_ADMIN_USER='' from main and from this branch, on a mongo:7 replica set and on cassandra:4.1 with PasswordAuthenticator.
- MongoDB on main stores an admin with an empty name (
_id: "").manage --user ''logs in as it, andchange-admin-password --admin-name ''works.delete-admin --admin-name ''gets HTTP 404. - Cassandra on main refuses the empty key (
Key may not be empty), soinitstops before the admin user and writes no row.initfrom this branch finishes that catalog and createsadmin.
c24442f and 138e712 rewrite the entry with both cases, by backend, and the commands I ran. On MongoDB that's create-admin for a named admin, then a deleteOne in mongosh for the one with the empty name.
The v1.1.0 entry for #1339 covered only an empty EXTENDDB_ADMIN_PASSWORD. In 1.0.0, an empty EXTENDDB_ADMIN_USER had a different result on each backend: - MongoDB stored an admin with an empty name. extenddb manage logs in as that admin with --user '' and changes its password with --admin-name '', but delete-admin --admin-name '' gets HTTP 404. The entry gives the create-admin and mongosh commands that delete it. - Cassandra refused the empty key, so init stopped before the admin user and wrote none. An init of this release finishes that catalog. The entry also gives the full change-admin-password command for an admin with an empty password.
The "Who is affected" lead now also names the Cassandra catalogs that init created with only EXTENDDB_ADMIN_PASSWORD set. The last paragraph of the entry gives them advice, and the lead left them out. "What changed" says what 1.0.0 did on each backend. On MongoDB it took the empty string as the name or the password. On Cassandra it took an empty password, and an empty name stopped init with an error. The MongoDB bullet no longer gives a cause for the HTTP 404 of delete-admin. The cause it gave did not tell that request apart from change-admin-password, which works. The mongosh step names the admin whose document it deletes. The Cassandra bullet drops a clause that repeats "What changed".
|
Thanks for the review, LJMart11. I ran the three checks you couldn't, at c24442f, which has main merged in (795a434):
The PR body has the full table of runs. On Cassandra I checked the new password with |
demohan
left a comment
There was a problem hiding this comment.
init reads the admin variables alike on every backend at 138e712. On Cassandra 4.1, main prints a supplied password in the credentials box when no name is set, stores an empty password, and stops with "Key may not be empty" on an empty name; this head answers all nine combinations of the name and password unset, empty or set as SQLite does and never prints a supplied password. SQLite and PostgreSQL answer as main on all nine, and no supplied password, superuser password or app password appears in any output, generated config or file under HOME. An existing catalog is still refused, a Cassandra catalog main's empty-name init left without an admin is finished with its key and default account kept, and a Cassandra catalog main created with an empty password keeps working until change-admin-password. Removing either shared filter or restoring main's from_env fails a test, the remedies in the upgrade entry work on Cassandra and MongoDB, fmt, both clippy commands and the 1.91.1 check are clean, and 1198 lib tests and both Cassandra tests pass.
CI's run-tests (1.91.1) stops at the secmem memlock test in crates/auth, so the new SQLite test has not run there yet, and the upgrade manual now conflicts with main's v1.1.0 entries; a merge of main and a rerun would settle both.
| * `EXTENDDB_ADMIN_USER` and `EXTENDDB_ADMIN_PASSWORD`: the first ExtendDB | ||
| administrator. Set both; with only the password set, `init` prints that | ||
| password in its output, and so in the container's logs. | ||
| administrator, named `admin` when `EXTENDDB_ADMIN_USER` is unset or empty. |
There was a problem hiding this comment.
Optional. The user line says "unset or empty" and the password line only "Without"; an empty EXTENDDB_ADMIN_PASSWORD also generates a password and prints it in the box.
| bootstrapper | ||
| .bootstrap_admin_user(admin_user, admin_password) | ||
| .bootstrap_admin_user( | ||
| admin_user.filter(|s| !s.is_empty()), |
There was a problem hiding this comment.
Optional. Only the SQLite test holds this filter; no test passes an empty value on MongoDB or Cassandra. A unit test here with a recording double, or Some("") as the user in the Cassandra resume test, would hold it for every backend.
|
|
||
| - An empty `EXTENDDB_ADMIN_PASSWORD` gave the admin an empty password. Log in with an empty `EXTENDDB_PASSWORD` and give the admin a password: `EXTENDDB_PASSWORD= extenddb manage --user <name> change-admin-password --admin-name <name> --new-password <password>`. | ||
| - On MongoDB, an empty `EXTENDDB_ADMIN_USER` gave the admin an empty name, and `list-admins` shows it as `"admin_name": ""`. That admin logs in with `--user ''`, and `change-admin-password --admin-name ''` changes its password. `delete-admin --admin-name ''` fails with `HTTP 404`. To delete the admin, first create another one: `extenddb manage --user '' create-admin --admin-name <name> --admin-password <password>`. Then delete the document of the admin with the empty name in `mongosh`: `db.getSiblingDB("extenddb_catalog").admin_users.deleteOne({_id: ""})`. | ||
| - On Cassandra, `init` with an empty `EXTENDDB_ADMIN_USER` stopped with `Error: Create admin user: Internal error: Database error` and wrote no admin, because Cassandra refuses an empty key. Run the same `init` command with this release. It finishes the catalog and creates the admin `admin`. |
There was a problem hiding this comment.
Optional. "Run the same init command with this release" works while the catalog is at migration 12; if a Cassandra catalog migration lands before the release, init refuses the catalog, so "run extenddb migrate first if init refuses" would cover it.
# Conflicts: # docs/manuals/07-upgrade-manual.md
|
Checked at Fixed:
Disputed: none. Needs-human: none. |
* chore(release): bump version to 1.1.0 Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker. * docs(upgrade): add the v1.1.0 entry of #1290, put #1349's in order #1290 merged after this branch was rebased. It changes the answer to a request with no Authorization header, so it gets a v1.1.0 entry. The merge of main put the #1349 entry after the #1523 entry. It moves to the place of its number, beside the new #1290 entry. --------- Co-authored-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
Resolve the Cargo.toml and Cargo.lock merge conflicts with main (v1.1.0) and adapt the Cloud Bigtable storage backend to upstream changes: - Align workspace Cargo.toml and Cargo.lock with ExtendDB v1.1.0 (ExtendDB#1514), MSRV 1.94.0 and sqlx 0.9.1 (ExtendDB#1166), and extenddb-server default-features = false (ExtendDB#1449), bumping extenddb-storage-bigtable to =1.1.0. - Adapt AuthorizationStore::fetch_session_data (ExtendDB#1523) to look up role session policy, tags, and RFC 3339 created_at in O(1) by access_key_id via iam_session_ak:<access_key_id> -> iam_session:<session_token> without re-checking session expiry, with symmetric 4 KiB row-key and non-empty token guards across fetch_session_data and lookup_credential. - Decide StreamSpecification transitions in BigtableEngine::update_table ahead of companion table fields and GSI updates (ExtendDB#963) so a refused disable/enable writes no other table member while still closing any open shards left behind by a prior disable. - Update docs/bigtable-setup.md for Rust 1.94.0 and the exact v1.1.0 extenddb version output. - Add unit and live cbtemulator integration tests covering session_data_conformance::run, expired/deleted/oversized session-data and credential lookups, write_bootstrap_rows admin environment-variable combinations and idempotent re-runs (ExtendDB#1349), ClientRequestToken NUL/backslash/ UTF-8 escaped stored tokens (ExtendDB#1375), and refused stream disable/enable preceding companion edits (ExtendDB#963).
Merge upstream main (ExtendDB v1.1.0) into rfc/bigtable-backend and reverse-sync docs/rfcs/0000-bigtable-backend.md with the v1.1.0 trait surface and conformance coverage: - Update ExtendDB binary version literals to v1.1.0 (ExtendDB#1514). - Document O(1) access-key-indexed AuthorizationStore::fetch_session_data (including expired sessions), symmetric 4 KiB key-length bounds, and session_data_conformance::run (ExtendDB#1523). - Document escaped ClientRequestToken stored tokens (ExtendDB#1375), pre-companion StreamSpecification refusal in TableEngine::update_table (ExtendDB#963), default SettingsStore::get_setting_bounded (ExtendDB#1449), and write_bootstrap_rows admin environment-variable handling (ExtendDB#1349).
Changes since the last review
docs/manuals/07-upgrade-manual.md, where main added the v1.1.0 entry of fix(deps): move to sqlx 0.9.1 for the SQLite fix of RUSTSEC-2026-0459 #1166 at the same place. Both entries stay, main's first.run-tests (1.91.1)failed insecmem::tests::init_refuses_under_a_low_memlock_limit_then_starts_unlocked. That failure is the SIGBUS that fix(auth): pre-fault the memfd_secret store with reads from /dev/zero #1522 fixes. Thewasmcheck failed on the break of main that fix(core): read the latency segment clock through web_time #1482 fixes. Main has both fixes now.cargo +1.97.0 fmt --all -- --checkpasses.cargo +1.97.0 clippy --all-targets -- -D warningswithextenddb-storage-cassandra/test-hooksandcargo +1.94.0 check --all-targetspass on the four crates.extenddb-storage295,extenddb-storage-cassandra192,extenddb-storage-postgres94 andextenddb-storage-sqlite335 (1 ignored).crates/storage-postgres/tests/doc_version_literals.rspasses too.What
extenddb initreadsEXTENDDB_ADMIN_USERandEXTENDDB_ADMIN_PASSWORDthe same way on every backend.crates/storage-cassandra/src/bootstrapper.rs: a password fromEXTENDDB_ADMIN_PASSWORDcounts as from the environment whether or notEXTENDDB_ADMIN_USERis set.initthen printsAdmin user 'admin' created (credentials from environment)., as on the other backends. It no longer prints the supplied password in its "shown once" credentials box.crates/storage/src/bootstrapper.rs:write_bootstrap_rowspasses an empty value of either variable on as no value, for every backend.initthen uses the nameadminand generates a password. Before, MongoDB took the empty string as the admin name or the password. Cassandra took an empty password, and an empty name stoppedinitwith an error. The SQLite and PostgreSQL bootstrappers had their own copy of this check, and this PR deletes those copies.bootstrap_dev_rows, because it writes its admin at start withoutwrite_bootstrap_rows.docker/README-cassandra.mdno longer says thatinitprints a supplied password.docs/manuals/07-upgrade-manual.mdhas a v1.1.0 entry for MongoDB and Cassandra catalogs that an earlier release initialized with an empty password or an empty admin name. The entry says what to do on each backend.Why
#1339. On main (5252eda), with
EXTENDDB_ADMIN_PASSWORDset andEXTENDDB_ADMIN_USERnot set, the Cassandra bootstrapper returned the supplied password as a generated one, andinitprinted it on stdout. A script or a container log that keeps the output ofinitkeeps the password with it. The management API refuses an empty admin name or password. On main,initon MongoDB accepted both, andiniton Cassandra accepted an empty password.Closes #1339
#1347 lists the other checks of the management API that
initdoes not apply to these variables.Testing done
At c24442f, with main 5252eda merged in. 138e712 changes only the wording of the upgrade entry.
I ran
initwithextenddbbuilt from main and from this branch, on amongo:7replica set and on acassandra:4.1node (4.1.12) withPasswordAuthenticator. After each run I read theadmin_usersrows. In the table, "supplied" is a 13-character password.EXTENDDB_ADMIN_USEREXTENDDB_ADMIN_PASSWORD"",Admin user '' created (credentials from environment).admin, from the environment""with an empty password, the same lineadmin, the box with a 24-character passwordadminwith an empty passwordadmin, the box with a 24-character passwordError: Create admin user: Internal error: Database error(the node answeredKey may not be empty), no admin rowadmin, from the environment or with a generated passwordadmin, the box with an empty passwordadmin, the box with a 24-character passwordadmin, the box with the supplied passwordadmin,Admin user 'admin' created (credentials from environment).Then I served the catalogs from main with this branch and ran the commands of the upgrade entry:
EXTENDDB_PASSWORD= extenddb manage --user admin change-admin-password --admin-name admin --new-password <password>exits 0. After it, an empty password getsHTTP 401: Invalid credentials, and the new password works.--user ''logs in, andlist-adminsshows"admin_name": "".change-admin-password --admin-name ''changes its password.delete-admin --admin-name ''getsHTTP 404, as that admin and as another admin.create-adminworks. Thendb.getSiblingDB("extenddb_catalog").admin_users.deleteOne({_id: ""})inmongoshdeletes the row (deletedCount: 1), and--user ''getsHTTP 401.initfrom this branch, with the same flags, finishes the catalog that main'sinitstopped. It printsFinishing a stopped init: the catalog is at migration 12 and has no admin user.and createsadmin.On Cassandra I checked the new password with
list-accounts.list-adminsanswersHTTP 500there on main and on this branch, because the row thatinitwrites has nocreated_at(#643).init_finishes_a_catalog_stopped_before_its_admin_userandinit_refuses_an_account_keyspace_at_simple_strategy_until_it_is_alteredincrates/storage-cassandra/tests/migrations.rspass on thecassandra:4.1node. With main's Cassandra bootstrapper, the first fails withleft: ("admin", false, false, Some("Supplied-pw-1")), so the supplied password came back as a generated one. Withfrom_envset to true for a generated password, the second fails atmigrations.rs:1617.empty_admin_variables_are_unset_and_a_supplied_password_is_not_returnedincrates/storage-sqlite/src/bootstrapper.rsrunswrite_bootstrap_rowsover four pairs of the two values in one table: both empty, a password alone, a name alone, and both. It passes on this branch, and it fails with the shared check deleted. Main's SQLite bootstrapper had its own check, so the test passes on main.init_finishes_a_catalog_stopped_before_its_admin_userpasses onpgvector/pgvector:pg16.extenddb-storage,extenddb-storage-cassandraandextenddb-storage-postgrespass, and so doescrates/storage-postgres/tests/doc_version_literals.rs. Inextenddb-storage-sqlite, 328 lib tests pass. Two tests inbackup_catalog.rs, which this PR does not change, fail on my host. ThereFilesystemStore::openrefuses their backup root, because a directory above it belongs to another user.cargo +1.97.0 fmt --all -- --check, the clippy commands ofclippy.ymlon those four crates, andcargo +1.91.1 check --all-targetson them: pass.cargo +1.97.0 clippy --all-targets -- -W clippy::pedanticon those four crates warns on no line that this PR adds.These open PRs add an entry at the same place in
docs/manuals/07-upgrade-manual.md: #368, #479, #484, #542, #546, #738, #1314 and #1427. #1166 merged on 26 November. At 5026c89, each of the eight conflicts in that file with main and with this branch.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
initwith an emptyEXTENDDB_ADMIN_USERorEXTENDDB_ADMIN_PASSWORDnow uses the nameadminor generates a password, where it used the empty string.initwith an emptyEXTENDDB_ADMIN_USERnow creates the adminadmin, where it stopped with an error. With an emptyEXTENDDB_ADMIN_PASSWORD, it generates a password, where it used the empty string.initwithEXTENDDB_ADMIN_PASSWORDset andEXTENDDB_ADMIN_USERnot set no longer prints the credentials box.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.