T13.3: Okta deprovisioning sync job, fail closed (D18)

run_sync() compares the Okta user list (T13.2) to active local accounts and
disables the ones Okta no longer vouches for. One AuditLog row per change,
actor system:okta_sync, action user_deprovisioned_by_sync.

Fail closed: any exception from the fetch, an empty or untrusted answer, or a
failed save changes nothing and writes nothing. The fetch runs before the
database is read, so a failed fetch has no path to a change. It only ever
disables; an already-disabled account is untouched and gets no new row.

Decided with Matt 2026-10-16: disable on missing, SUSPENDED or DEPROVISIONED.
PASSWORD_EXPIRED, LOCKED_OUT and RECOVERY do not disable (the job never
re-enables, so a literal "not ACTIVE" would lock people out for good).
Added a guard: no match between any active local account and any Okta user is
refused as a wrong identity attribute, not read as a mass offboarding.

tests/okta_sync_job_check.py: 71 checks; removing the fail-closed branch and the
guard fails 28 of them. BL-069 logs the missing per-run cap.
This commit is contained in:
2026-10-16 11:31:39 -07:00
parent 2f7de6e33b
commit 103e4d40ee
4 changed files with 402 additions and 8 deletions

View File

@@ -662,3 +662,20 @@ deliberately deferred.
worth confirming rather than assuming).
- **Suggested wave or follow-up:** next housekeeping pass — needs Nick on
whether to delete, archive, or rewrite it as historical record.
### BL-069 - The sync has no cap on one run and no last-admin guard
- **Found during:** T13.3 (D18)
- **Where:** `server/okta_sync.py` `run_sync()`
- **What:** a run disables every account the rules select, however many. If the
identity attribute is partly wrong (it matches some accounts and not others),
one run can disable most of the company, including every admin. The
zero-match guard only stops the case where nothing matches. Disabled accounts
cannot sign in, so re-enabling needs an admin who is still active, or the
`manage_users.py` command line on the host.
- **Why not now:** D18 does not ask for it, and the right limit is a product
call: a count, a share of accounts, a rule that the last active admin never
disables, or all three.
- **Suggested wave or follow-up:** before the first live run, or in T13.6 if
Matt decides. Needs Matt.