Skip to content

A plane holds one row per person and per group: a push or a sign-in that finds nobody under its subject reuses the row SCIM gave that externalId, duplicates are merged into SCIM's row before users.external_id is made unique, and a SCIM DELETE removes a person behind a tombstone and a group with the team built on it alone

Decision 899 · accepted · 2026-10-13 · issue #707 · supersedes 754, 759

Superseded in part

In part by 906, 914.

Issue #707. A plane fed by SCIM and by sign-in showed the same person, and the same group, more than once, and a SCIM DELETE removed nothing. It replaces the part of Decision 759 that made a DELETE soft ("One way to deactivate" names a DELETE among the ways to deactivate) and the sentence of Decision 754 that has a group's DELETE empty it. The rest of both stands: active: false in a push or a PATCH still deactivates and keeps the row, and a POST of somebody the plane has is still a create.

  • A person is found by their externalId too. A push keys on its subject, externalId else userName; one that finds nobody under it but finds a row whose external_id is the externalId it carries updates that row and keeps that row's subject. A sign-in that finds nobody under its subject, after Decision 751's move, but finds a row whose external_id is that subject moves the row there with Identity.rekey/2, the same move, audited as person.rekey. SCIM names a person by the value the subject claim carries, so a row whose external_id is not its subject is one a sign-in under another claim moved; without this, the next push after a subject_claim switch made a second row with the same external_id, and switching back made a second row at sign-in. A deactivated row found this way is still refused (Decision 381).
  • users.external_id is unique where set, a partial index, and User.changeset/2 reports a clash as a changeset error, so a push that would give a second row the value answers 400 rather than 500.
  • The duplicates already there are merged by the migration, not by an admin task: the index must come after the merge and before the plane serves, and a task run after the upgrade would leave the index unbuildable on exactly the planes that need it. One person is every row whose external_id is the value, and every row whose subject is the value that SCIM has not named otherwise. The row kept is SCIM's, since its id is what the provider holds: the one whose subject is also the value, else the newest carrying it, which the provider created last. The others are folded into it as Decision 751 folds a moved person: sessions (owner and owner id), ACL entries, shares made out to them, team administration, sponsored principals, the sponsor in a run's origin, triggers' notify, usage records and open reservations move; the audit trail and every *_by keep the name they were written with. The kept row takes the key-manager name of the row known first, under which what they stored before there were two is, and its own ceiling, else a folded row's. Each set is one person.merge row on the audit trail, chained like every other, with the kept and folded ids and subjects and the key-manager names left behind, and is logged.
  • What only looks alike is reported, not merged. The same email or display name under different keys proves nothing: two people may share an address, and only the provider knows which of a group's two ids is right. Identity.lookalikes/0 lists such sets with where each row came from (a sign-in writes neither externalId nor userName) and the mismatch it most likely comes from: the subject claim against SCIM's externalId for a person, a groups claim naming a group by its name while SCIM pushes its id for a group. A pair sharing an externalId never appears, since it was merged.
  • A SCIM DELETE of a person removes the row. GET and DELETE of the id answer 404 afterwards and filters do not find them. A tombstone (person_tombstones) keeps the former id, subject, externalId, userName, display name and key-manager name. Their team sessions that are running or waiting are parked first, each giving back its slot and its slice under the subject it was reserved for; then all their sessions go read-only and are owned by the tombstone's marker, removed:<tombstone id>, so nothing matches them to a subject again. They stop administering every team, their ACL entries go, shares made out to them are revoked, and the principals they sponsor stop (sponsor_left, as a deactivation does). Their memberships go with the row. Audited as person.remove by scim, under the subject they had, with what was done.
  • Somebody the provider sends later under the same subject is somebody new. They do not inherit the removed person's sessions, ACL entries or administration, and are not given the removed person's key-manager name, which a tombstone holds as a user row does: whatever the removed person stored there stays theirs, for an erasure (#636) to remove, and an erasure of their private sessions finds it through the marker (Identity.kms_name_of/1). A provider deleting somebody is offboarding them; handing a re-hire the old sessions would be a decision about access that the provider did not make, and is not made here.
  • A SCIM DELETE of a group removes it with its memberships and links. A team built on it and on no other group is disabled as an administrator would disable it: grants revoked with their sessions read-only and the profiles' teams written again, its triggers deleted, then the row, audited as team.disable by scim. A team that draws from other groups too keeps them, and its group_id, the record of which group it was enabled from, moves to one of them, since the database deletes a team with the group it records. The group's own deletion is audited as group.delete, naming the teams disabled and kept.

Governs: apps/troupe_plane/lib/troupe/plane/scim.ex, apps/troupe_plane/lib/troupe/plane/login.ex, apps/troupe_plane/lib/troupe/plane/identity.ex, apps/troupe_plane/lib/troupe/plane/identity/tombstone.ex