Repository navigation
fix(iam): delete what a principal or account owns with it - #923
Conversation
Inline policies and permissions boundaries are stored by principal name with no foreign key to the principal, and MongoDB and Cassandra link no IAM record to its principal or account. A delete left them behind, and a principal created later with the same name, or an account with the same id, got them and their permissions (#693, #694). - SQLite, PostgreSQL: a user, group or role delete also deletes its inline policies and boundary, in the principal's transaction. - MongoDB: a user delete also deletes its boundary and tags, a group delete its policies and memberships, a role delete its policies, boundary, tags and sessions. Errors are returned, not ignored. - Cassandra: a group delete also deletes its policies and memberships, a user delete its boundary, a role delete its policies, boundary, tags and sessions. - MongoDB, Cassandra: an account delete deletes the account's users, groups, roles and all they own. What a principal or account owns goes before its own record, so a failure leaves less, never more. - Every backend: a user, group or role create, after its own insert, also deletes rows stored under its name, so rows an earlier release left are cleared. MongoDB and Cassandra do the same for an account id. MongoDB now refuses a taken account id on create. - MongoDB, Cassandra: a user, access key, session or role of an account that no longer exists is unknown when signing in or assuming a role. extenddb_storage::iam_leftovers_conformance (feature test-util) checks this against a real database; each backend's suite runs it. Fixes #693. Fixes #694.
Putting an inline policy or a permissions boundary on a user, group or role that does not exist answered 204 and stored it under the name, so it waited for the next principal created with that name. The management API and the console now answer 404 "IAM <type> not found", as IAM answers NoSuchEntity. A create also clears such rows, which covers a put that races a delete.
Each test gives a role, user, group or account everything it can own, deletes it, checks that its credentials stop working, creates it again with the same name or id, and checks that it starts empty. Two more check that a policy or boundary put on a missing principal is refused with 404.
The getting-started and admin guides list what a user, group, role or account delete removes. The upgrade manual has a v0.1.15 entry, the differences document compares the delete and the put with IAM's DeleteConflict and NoSuchEntity, and the storage guide states the cascade rules a backend must follow.
A principal's create or delete returned an error, such as AlreadyExists or NotFound, by dropping its BEGIN IMMEDIATE transaction. Dropping a SQLite transaction only queues its rollback, and a BEGIN IMMEDIATE on the connection before the rollback ran failed with "attempted to call begin_with at non-zero transaction depth", so the next write on that connection answered 500. The creates and deletes now commit or roll back through one helper before they return.
navareamol
left a comment
There was a problem hiding this comment.
No blocking findings. Two things to settle:
- CI is red and the branch is behind main.
run-testsfails onpanicking_refresh_does_not_leak_inflight_flagincrates/cache, which this PR does not touch. It passed 100 of 100 runs on main here, so I think it is a flake. Could you update the branch and rerun it? CodeQL also reports 4 "hard-coded cryptographic value" alerts on the test passwords iniam_leftovers.rsandlive_tests.rs. Could you generate the password in the test, or dismiss the alerts with a comment? - The description says a deleted principal leaves nothing behind, but the failed-login history in
login_attemptsis keyed by name and follows it. Measured on SQLite and Cassandra: 6 wrong passwords for a user, delete the user, create the same name again, then the correct password from the same address gets 429 for up to 15 minutes. It is the same on main, so this PR does not cause it. Could you clear that name'slogin_attemptsrows in the delete and the create, or narrow the claim in the description? Filing it as its own issue also works for me.
The wire tests pass on SQLite, PostgreSQL and Cassandra. On main, 8 of the 9 fail on SQLite, as the description says. The two Cassandra direct tests pass too.
I'll approve once 1 is green and 2 is settled.
| let cleared = self | ||
| .delete_principal_dependents(account_id, principal_type, principal_name) | ||
| .await; | ||
| if cleared.is_err() |
There was a problem hiding this comment.
If the clear fails and the delete of the new row fails too, the second error is only logged and the create returns the first. The principal then exists with the old rows still under it. A retry of the create gets 409 and skips the clear, so nothing removes them. Is anything else clearing them in that case? I read this from the code and did not inject the failure.
There was a problem hiding this comment.
Nothing else clears them: only a delete of that principal or of its account removes the rows. A process that stops between the insert and the end of the clear leaves the same state. Filed as #962.
panicking_refresh_does_not_leak_inflight_flag slept a fixed 50 ms after the refresh that panics, and expected the next stale read to start a new refresh. On a busy CI runner the spawned task had not yet run and been dropped by then, so the flag was still set and the read was counted as refresh_skipped_inflight. It failed that way on main, on merge-queue runs for #827 and #833, and on this branch. A 60 ms delay before the panic reproduces it every time. Give the test a 60 s hard TTL, so a hard miss cannot hide a leaked flag, and wait with a 10 s deadline: first for the panicking refresh to run, then for a stale read to start a refresh that succeeds. With the RAII guard removed the test still fails, at the deadline.
# Conflicts: # docs/manuals/07-upgrade-manual.md
The Cassandra and MongoDB tests that sign in a user of a deleted account hashed and checked a password written in the source, which CodeQL reports as a hard-coded cryptographic value (4 alerts). Generate it per run instead; the tests check the same thing.
Failed logins are recorded under the sign-in name, account_id/user_name, with no link to the user. A user created with the name of a deleted one started with its failures: after five wrong passwords, a delete and a create of the same name, the right password got 429 from that address for up to 15 minutes. A user's delete and create now delete the failed logins under its sign-in name, and an account's delete those under every account_id/ name, on all four backends. SQLite and PostgreSQL do it in the same transaction as the principal, MongoDB and Cassandra with the rest of what the principal or account owns. The account prefix is matched literally (substr, starts_with, an escaped anchored regex, a filtered read of the partition keys), so another account whose id starts with the same digits keeps its failures. The conformance check covers the user's delete, a create over a name with failures, and the account's delete, including the other account. Three wire tests send the reviewer's sequence. Both fail without the change. The per-address limit is unchanged.
|
Thanks @navareamol. Both points are addressed in the commits pushed to 1. CI and the branch
2. You were right: failed logins are keyed by the sign-in name
Tests:
|
The two MongoDB tests that check a deleted principal or account leaves nothing behind lived in src/management_store/live_tests.rs, ignored unless run with --ignored. Move them to tests/iam_leftovers.rs as direct integration tests: they call the catalog store against a live replica set with no ExtendDB server in between, as the Cassandra crate's tests/direct_integration.rs does. They use the migration tests' Deployment for their scratch databases, and skip without EXTENDDB_TEST_MONGODB_URI unless EXTENDDB_TEST_MONGODB_REQUIRED is 1, which run-mongodb-tests sets. The one crate-private item they need, MongoCatalogStore::on_database, is reached through on_database_for_tests, compiled only with the test-util feature that the crate's test builds enable.
On Cassandra, login_attempts is keyed by (principal, attempted_at) with attempted_at in milliseconds, so the conformance check's three back-to-back failures can land in one millisecond and overwrite each other: cassandra-storage counted 2 where the check expected 3. The check is about failures going away, so it now asserts they are present before the delete and in the other account afterwards, and absent where a delete or create clears them. The assertion and panic messages named the sign-in name, which carries the account id; CodeQL reports that as cleartext logging. They now name a fixed label instead.
navareamol
left a comment
There was a problem hiding this comment.
Both points are fixed at bb9b025, and CI is green. The failed-login history now goes with the name on delete, create and account delete, and the tests I ran on SQLite, PostgreSQL and Cassandra pass.
One follow-up, not for this PR: if the cleanup in clear_new_principal fails and removing the new row fails too, a retry gets 409 and the old rows stay. Could you file an issue for it? Approving.
# Conflicts: # crates/storage-cassandra/tests/direct_integration.rs
# Conflicts: # docs/manuals/07-upgrade-manual.md
Main at 06534e1 adds #228, #923, #475, #732 and #900 since the last merge. One file conflicted: crates/storage-postgres/src/backup_catalog.rs. #900 moves the insert statement of insert_backup_row into a new function, insert_unowned_row. The legacy reader's replace_with_index_row runs that function inside its own transaction. On this branch, the same insert stores source_table_details_json through escape_json. The merge keeps main's function and adds the escape to it, so both callers store the escaped form that row_from_tuple reads back. The module comment now names insert_unowned_row in place of insert_backup_row. Main adds no other write of a catalog document that carries attribute names. #900's legacy reader takes the source table from restore_source, which reads the stored documents through from_catalog_json and unescape_json. Against main, the merged tree changes the same 44 files, with the same line counts, as this branch did against its merge base. In backup_catalog.rs the escape of the unowned insert is in insert_unowned_row, and the module comment names that function.
#923 on main gave panicking_refresh_does_not_leak_inflight_flag a TTL of Duration::from_secs(60). With rust-version at 1.91.1, the pedantic lint clippy::duration_suboptimal_units asks for Duration::from_mins(1) there, and cargo clippy --all-targets -- -D warnings fails on it.
#923 on main gave panicking_refresh_does_not_leak_inflight_flag a TTL of Duration::from_secs(60). With rust-version at 1.91.1, the pedantic lint clippy::duration_suboptimal_units asks for Duration::from_mins(1) there, and cargo clippy --all-targets -- -D warnings fails on it.
…t version to 1.91.1 (ExtendDB#857) * fix(deps): update aws-smithy-json to 0.62.7 Cargo.lock: aws-smithy-json moves from 0.62.3 to 0.62.7. Versions up to 0.62.6 recurse without a depth limit while skipping an unknown key, so a deeply nested document can exhaust the stack (CVE-2026-18140, GHSA-8ffr-xgwf-xj56). In this workspace only the AWS SDK clients behind extenddb-backup-store use the crate: aws-config, aws-sdk-s3, aws-sdk-sso, aws-sdk-ssooidc and aws-sdk-sts. aws-sdk-s3 and aws-sdk-sts use it only for the compiled-in endpoint partition table. aws-sdk-sso and aws-sdk-ssooidc also parse the SSO and SSO OIDC responses with it. aws-config parses the credentials it reads from IMDS, the container endpoint, a credential_process command and the SSO token cache. 0.62.7 requires aws-smithy-runtime-api 1.12.3 or newer, so the lock also moves aws-smithy-runtime-api from 1.11.3 to 1.12.3, aws-smithy-types from 1.4.3 to 1.4.9 and aws-smithy-async from 1.2.11 to 1.2.14, and adds aws-smithy-runtime-api-macros 1.0.0 and aws-smithy-schema 0.1.0. Each is the lowest version the new requirements accept. No other package moves, and each aws-smithy crate resolves to one version. The six crates declare rustc 1.91.1 as their minimum, above the workspace rust-version of 1.88, so a 1.88 toolchain refuses to build extenddb-backup-store with this lock. Since ExtendDB#672 the extenddb binary links extenddb-backup-store through extenddb-app, so the release images and npm binaries carry aws-smithy-json. Built from main they link 0.62.3. With this change they link 0.62.7. * build: raise the minimum Rust version to 1.91.1 aws-smithy-json 0.62.7, the first release with the fix for CVE-2026-18140, and the five aws-smithy crates it needs declare rustc 1.91.1 as their minimum. The workspace minimum was 1.88. Cargo.toml sets rust-version to 1.91.1. The comment on the aws-sdk pins now says that each pinned version declares a minimum at or below the workspace rust-version, and .cargo/config.toml names 1.91.1 for the resolver fallback. The comments next to the three compare-exchange loops that stand in for fetch_update now name 1.91.1: the replacement, try_update, is still unstable there. clippy reads the minimum from rust-version, and from 1.91 it asks for Duration::from_mins where a value is a whole number of minutes. The four cases are in extenddb-cache: the default TTL in swr.rs and three lines of tests.rs now use Duration::from_mins(1). * ci: run the minimum version leg of test.yml on Rust 1.91.1 The workspace rust-version is 1.91.1, so the leg that checks the minimum moves from 1.88.0 to 1.91.1. * docs: name Rust 1.91.1 as the minimum version README.md, CONTRIBUTING.md, the getting started page, the quick start and install manuals and the backup design name 1.91.1, the workspace rust-version. * build: build the images on Rust 1.91.1 The four Dockerfiles build on rust:1.91.1-bookworm, pinned by digest. Cargo refuses to build a package on a compiler older than its rust-version, so the 1.88 build stage would fail on every image. * docs: name Rust 1.91.1 in the contributor and setup notes AGENTS.md and the setup references under .agents/skills name 1.91.1, the workspace rust-version. * chore(licenses): regenerate the notices for aws-smithy-json 0.62.7 Since ExtendDB#672 the server links the AWS SDK clients, so the four notices files list the aws-smithy crates. They listed the versions from before this branch's lock update. The files now list aws-smithy-json 0.62.7, aws-smithy-runtime-api 1.12.3, aws-smithy-types 1.4.9 and aws-smithy-async 1.2.14, and add aws-smithy-runtime-api-macros 1.0.0 and aws-smithy-schema 0.1.0. devtools/generate-software-license-notices for the postgres, mongodb and cassandra backends and devtools/generate-dev-license-notices wrote the files with cargo-about 0.9.0, the version CI pins. Each script passes with --check. * test(engine): name Rust 1.91.1 in a backup test comment A backup test merged from main says that the replacement for fetch_update is not on Rust 1.88. The workspace minimum is now 1.91.1, so the comment names 1.91.1, as the two migration comments on this branch do. * docs: build the deployment guide example on rust:1.91.1-bookworm The example Dockerfile in the deployment guide says to match rust-version in Cargo.toml, and builds on rust:1.95. rust-version is now 1.91.1, so the example builds on 1.91.1. The rust image tags without a suffix are the Debian trixie images, and the example's runtime stage is debian:bookworm-slim. A binary linked against glibc 2.41 on trixie can need symbols that glibc 2.36 on bookworm does not have. The example now builds on the bookworm image, as the four Dockerfiles do. * docs: say that try_update is unstable on 1.91.1 The comments on three compare-exchange loops say that the replacement for fetch_update does not exist on Rust 1.91.1, or is not on it. It exists there as an unstable API, behind the atomic_try_update feature, so the comments now say that it is unstable on 1.91.1. * docs: drop Rust 1.88 from the resolver comment and the crate README The crates.io work on main added two statements of the minimum Rust version after this branch raised it to 1.91.1. The resolver comment in Cargo.toml now refers to the workspace rust-version and names no number. The install section of crates/bin/README.md names 1.91.1. ADR-0029 keeps 1.88. ADRs are not edited after acceptance (docs/adr/README.md), and this change keeps the decision that ADR-0029 records. * test(cache): use Duration::from_mins in the panicking refresh test ExtendDB#923 on main gave panicking_refresh_does_not_leak_inflight_flag a TTL of Duration::from_secs(60). With rust-version at 1.91.1, the pedantic lint clippy::duration_suboptimal_units asks for Duration::from_mins(1) there, and cargo clippy --all-targets -- -D warnings fails on it. * docs(cargo): say that supported builds use the committed lockfile Resolver 3 and the resolver fallback make a bare cargo update or an unlocked cargo install less likely to move the pinned aws-sdk graph. They do not prevent it. At rust-version 1.91.1 such a resolve raises aws-smithy-types to 1.5.0, which does not build with the pinned aws-runtime 1.6.0 (E0282 in aws-runtime's sigv4 module). The comments in Cargo.toml and .cargo/config.toml said the fallback stopped that. They also said the 1.91.1 leg of test.yml caught drift, but that leg builds with --locked and never resolves afresh. The comments now say that a build using the committed Cargo.lock gets the recorded versions. They add that the release images pass --locked, and that cargo install extenddb should pass it too. * docs(setup): use the real 1.91.1 rustc banner in the version-parsing note The dependency-check note gave rustc 1.91.1 (abcdef0 2025-01-01) as the sample version line. That commit hash and date are not real. rustc 1.91.1 prints (ed61e7d7e 2025-11-07). Use that so the awk example matches what the toolchain prints.
) * fix(devtools): wait for the MongoDB primary on a condition check-mongodb-auth fails intermittently with "create the administrator: MongoServerError: not primary" (main 2026-11-10 twice, merge queue for ExtendDB#830 and ExtendDB#901, and PR ExtendDB#923). Its readiness probe took a refused connection for success: mongosh prints "connect ECONNREFUSED 127.0.0.1:27081", which passes `.endswith("1")` on CI's port 27081. When mongod started slowly, rs.initiate ran against a closed port, its result was ignored, the primary loop ran out its 60 tries silently, and the next command reported the misleading "not primary". start_mongo had the probe fixed in ExtendDB#672 but also ignored the initiate. Both now call become_primary: one mongosh --nodb process waits for mongod to answer, initiates rs0 (skipped if hello already names a set), and waits for the election with an awaitable hello rather than sleep and retry, all against one deadline. A failure names the step that ran out of time with what it last saw and the container's log. Tested against a local mongod 7.0 with a key file through a docker stand-in: mongod started 5 s after the waiter (the CI race) became primary and took the first user under the localhost exception; a second call succeeds; with nothing listening it fails after its deadline naming the refused connection. * fix(devtools): Pause on error replies, read last line Address review on ExtendDB#952. become_primary required stdout and stderr together to be exactly `primary`, so a warning mongosh prints on either stream failed the step while the member was primary. It now reads the last line of stdout and keeps the combined output for the failure text. Two paths in the script looped with no pause until the deadline: a ping answering with ok other than 1 (opening a new connection each time), and a hello returning an error document, which has no topologyVersion to wait on. Both now sleep 100 ms; the ping path closes its connection and keeps the reply in `last`, and the hello timeout already names the last reply. --------- Co-authored-by: Hitesh Sharma <hts@amazon.com>
The storage-level section of run-mongodb-tests listed seven test files. Main added tests/secret_rows.rs after this branch's base, and after the merge nothing ran it against a server. mongodb-rust no longer runs the workspace `cargo test`, and the Test workflow has no MongoDB server, so the file's three tests skip there. The section now runs `cargo test -p extenddb-storage-mongodb --tests` with EXTENDDB_TEST_MONGODB_URI and EXTENDDB_TEST_MONGODB_REQUIRED=1, so a new file under tests/ runs without an edit. It skips the snapshot_engine unit tests, which mongodb-snapshot runs. With REQUIRED set, a_standalone_server_is_unsupported fails when EXTENDDB_TEST_MONGODB_STANDALONE_URI is unset, and cargo then stops before the files under tests/. The --rust-live section ran tests/iam_leftovers.rs one test at a time, and the storage-level section now runs it too. Neither the commit that added the serial run nor #923 gives a reason for it. Each test makes databases of its own, and main's mongodb-rust job ran both tests in parallel in its workspace `cargo test` (run 45436870031). This commit removes that section, and the file's comment now says which arguments set REQUIRED.
…hards (ExtendDB#911) * ci: run only the MongoDB-backed Rust tests in mongodb-rust mongodb-rust passed --rust to run-mongodb-tests, which runs the whole workspace's `cargo test` against the job's server. On main's push run for 76b9710 that took 11 minutes. Building the workspace's test binaries took 3 min 54 s, and running every crate's tests took 7 minutes. The Test workflow runs the same tests on stable and on 1.88. The job now passes only --rust-integration. The tests that need MongoDB still run against a replica set: - records_live and the five migration test files run in the storage-level sections of run-mongodb-tests. Their condition now names both Rust suites. - The data_engine and backup_engine live tests and the restore fence cells run under --rust-live. - The snapshot_engine tests run in mongodb-snapshot, with EXTENDDB_TEST_MONGODB_REQUIRED set. No other workspace test reads EXTENDDB_TEST_MONGODB_URI. * ci: say when the MongoDB storage-level sections run The comment said that the records_live and migration sections of run-mongodb-tests run for either Rust suite. They run when the arguments name --rust or --rust-integration, and not for --all, which run-tests expands to both suites. The comment now says so, and it names the tests that mongodb-rust runs in these sections. * ci: stop repeating the backup suites on every integration shard On the CI run of d9528e6 (run 42637473269), every shard of run-integration and run-integration-sqlite ran tests/test_backup_store_config.py and tests/test_backup_job.py by name. The two files took 2 min 52 s to 3 min 8 s on each PostgreSQL shard. The S3 mock took 22 to 28 s more. On each SQLite shard the two files took 4 min 28 s to 4 min 30 s. Each SQLite shard also ran the store configuration suite a second time inside devtools/run-tests, against an S3 mock of its own. That run took 2 min 45 s to 2 min 46 s. - PostgreSQL: the new run-integration-backup job runs the two files once, with the shards' PostgreSQL service, the S3 mock and the same environment. The integration job needs it. The CLI lifecycle list of devtools/run-tests still runs the store configuration suite's PostgreSQL cells on one shard. - SQLite: the shards run neither file. devtools/run-tests skips its SQLite backup store block in a run with --shard. The shards no longer start the S3 mock, whose one reader was that block. run-integration-sqlite-s3 runs both files on the same build with the S3 mock. On run 42637473269 it passed every test that a SQLite shard passed in either of those runs. The timeout comments give the measured times and the projected time of a shard. * ci: run every storage-mongodb test target against the replica set The storage-level section of run-mongodb-tests listed seven test files. Main added tests/secret_rows.rs after this branch's base, and after the merge nothing ran it against a server. mongodb-rust no longer runs the workspace `cargo test`, and the Test workflow has no MongoDB server, so the file's three tests skip there. The section now runs `cargo test -p extenddb-storage-mongodb --tests` with EXTENDDB_TEST_MONGODB_URI and EXTENDDB_TEST_MONGODB_REQUIRED=1, so a new file under tests/ runs without an edit. It skips the snapshot_engine unit tests, which mongodb-snapshot runs. With REQUIRED set, a_standalone_server_is_unsupported fails when EXTENDDB_TEST_MONGODB_STANDALONE_URI is unset, and cargo then stops before the files under tests/. The --rust-live section ran tests/iam_leftovers.rs one test at a time, and the storage-level section now runs it too. Neither the commit that added the serial run nor ExtendDB#923 gives a reason for it. Each test makes databases of its own, and main's mongodb-rust job ran both tests in parallel in its workspace `cargo test` (run 45436870031). This commit removes that section, and the file's comment now says which arguments set REQUIRED. * ci: bound run-integration-backup at 25 minutes, with main's timings The three timing comments gave this branch's run of 9 Nov. Since then tests/test_backup_job.py grew from 1543 to 4712 lines on main. Main ran the Integration workflow for 25 pushes from 18 to 25 Nov. In those runs the backup store and job suites step took 7.3 to 9.1 minutes on the PostgreSQL shards. On the SQLite shards it took 5.9 to 7.5 minutes. With the 61 s of steps before it, the longest of those runs leaves run-integration-backup about 5 minutes under a 15-minute bound. run-integration-backup now stops at 25 minutes. The comments of the two shard jobs and of run-integration-backup give main's step and job times with their date range. * ci: leave the store configuration suite out of the sharded CLI list Under --shard, the CLI lifecycle list of run-tests still named tests/test_backup_store_config.py, so one PostgreSQL shard ran the file's PostgreSQL cells without the S3 mock. run-integration-backup runs the whole file with the mock, so those cells ran twice in each CI run. The list now takes the file only in a run without --shard, as the SQLite block already does. A local run without --shard keeps it. The --shard help, the comments beside the list and the comment of run-integration-backup say so. * ci: give CI's mongodb-rust arguments as the run-mongodb-tests example The usage example still passed --rust, which runs the workspace `cargo test` that mongodb-rust no longer runs. It now shows the job's line, `--rust-live -- --rust-integration`. This also corrects two sentences of the message of d9528e6 for the tree after the merge of main. The Test workflow's second toolchain is now 1.91.1, not 1.88. tests/secret_rows.rs, which main added after this branch's base, also reads EXTENDDB_TEST_MONGODB_URI, and 7e7918c runs it.
What
A deleted user, group, role or account now leaves nothing behind for one created later with the same name or ID, on all four backends.
Inline policies and permissions boundaries are stored by principal name, with no foreign key to the principal. On MongoDB and Cassandra, no IAM record is linked to its principal or account at all. Before this change, each delete path removed a different subset (read from
mainat35edb778):Changes:
delete_usernow returns errors from these deletes; before, it ignored them.accountscollection is unique onaccount_nameonly, socreate_accountnow checks the ID first. Before, a second account with the same ID could be created, and the cleanup on create must never reach a live account.IAM <user|group|role> not foundinstead of 204, as IAM answersNoSuchEntity. The check is in the server: the storage methods stay plain data access, and the cleanup on create covers a put that races a delete.BEGIN IMMEDIATEon that connection before the rollback ran failed withattempted to call begin_with at non-zero transaction depth. That already happened oncreate_user's error paths; the newNotFoundandAlreadyExistsreturns made it frequent. The creates and deletes now commit or roll back explicitly before they return.I kept cascade rather than IAM's
DeleteConflictrefusal: ExtendDB already cascades access keys, tags and memberships, and refusing would break existing callers.docs/differences-from-dynamodb.mdrecords the difference.Why
Closes #693.
Closes #694.
A principal created with a deleted principal's name got its permissions: an inline policy or boundary on every backend, and on MongoDB and Cassandra also its access keys, sessions or group members. On MongoDB and Cassandra, a deleted account's users stayed in the catalog with their password hashes.
On SQLite, on
main(35edb778), I reproduced the role, user and group cases withextenddb manage. A recreated role listed the old policy and boundary, and a new session of it was allowedListTables. A recreated user and a recreated group behaved the same way.Testing done
extenddb_storage::iam_leftovers_conformance(featuretest-util). Each backend's suite runs it against a real database. It checks that a delete leaves no policy or boundary, that a create over rows stored under its name starts empty, that a refused duplicate create keeps the live principal's policies and boundary, and that an account created again with the same ID has no principals or policies.tests/iam_leftovers.rs): pass.main'susers.rs,groups.rsandroles.rson both backends. With only the cleanup in SQLite'screate_userremoved, it fails at "created over rows left under its name".management_store::live_tests, added todevtools/run-mongodb-tests --rust-live) and Cassandra (tests/direct/iam_leftovers.rs): not run locally, because this machine has neither. Both also test that a user and role of a deleted account (only the account record removed) cannot log in or be assumed. The credential stores' new checks have no unit test: MongoDB's hard-codes theextenddb_catalogdatabase, and Cassandra's is private to the crate.tests/test_iam_delete_leftovers.py(9 tests, all backends). For a role, user, group and account, it gives each everything it can own, deletes it, checks that its key or session is refused, creates it again, and checks that it starts empty and denied. It also checks that the account's user can no longer log in through the management API or the console. Two tests check the 404 on a missing principal.main's SQLite build, 8 of the 9 fail. The account test passes there, as expected: the foreign keys already cascade an account delete on SQLite. Its failure would show on MongoDB and Cassandra, which I could not run.mainmerged.cargo +1.97.0 fmt --all -- --check: clean.cargo +1.97.0 clippy --all-targets -- -D warningson the six changed crates, with both feature sets ofclippy.yml: clean. The workspace-wide run stops at an unused variable incrates/core/tests/data_file_decode_peak.rs, which this branch does not touch.cargo +1.88.0 checkon the changed crates: OK.cargo test --libfor storage, storage-sqlite, storage-mongodb, storage-cassandra and server: pass.cargo test -p extenddb-storage-postgres --testsagainst PostgreSQL 17: 395 passed. 4 failed, and they fail the same way onmainhere: the 3migrate_data_db_nametests need a password in the connection string, anda_role_that_does_not_own_the_tables_is_told_what_to_rundepends on the local superuser setup.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. No schema, trait or wire change. The management API now answers 404 where it answered 204 for a policy or boundary on a missing principal.
Breaking changes
PUT .../users|groups|roles/{name}/policy/{policy}andPUT .../users|roles/{name}/permissions-boundaryon a principal that does not exist answer 404IAM <type> not found, where they answered 204. A script that attaches before it creates must create first.create-accountwith an account ID that is already in use answersAccount already exists.The upgrade manual has a v0.1.15 entry. No catalog migration is required.
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.