T13.2: Okta Management API client (D18)

New server/okta_sync.py: lists every Okta user and status with its own
read-only credential (OKTA_API_TOKEN, SSWS), separate from the OIDC client.
Follows pagination. Every failure raises OktaSyncError; an error is never an
empty list, because T13.3 reads an empty list as "nobody is active".

Also refuses: a next-page link to another host (token never leaves the org),
a redirect, a chain over 50 pages (a cut-off list looks like missing users),
a bad item among good ones (never skipped), and an empty list.

tests/okta_sync_check.py: 52 checks, self-contained (httpx MockTransport).
Not wired into app.py yet. T13.3 uses it; T13.4 starts it on a schedule.
This commit is contained in:
2026-10-16 11:28:57 -07:00
parent da1325c8a1
commit 2f7de6e33b
4 changed files with 472 additions and 4 deletions

View File

@@ -65,6 +65,30 @@ OKTA_REDIRECT_URI=CHANGE_ME
# a custom claim, …) — no code change needed, just this value.
# OKTA_IDENTITY_CLAIM=preferred_username
# ── Okta deprovisioning sync (D18, wave 13) ────────────────────────────────────
# A scheduled job asks Okta who is still active and disables local accounts
# Okta no longer shows as active. It only ever DISABLES. It never re-enables.
# If Okta cannot be reached or answers with anything unexpected, the job changes
# NOTHING that cycle and logs the failure.
#
# A read-only Okta API token, created by the person who administers the Okta
# tenant (Security > API > Tokens). This is NOT the OIDC client secret above.
# It is a different credential with a different scope. Treat it like
# AUTH_SECRET_KEY: never commit it, never log it. Leave it unset and the sync
# stays off (the startup log says so).
# OKTA_API_TOKEN=CHANGE_ME
#
# The Okta org URL that serves the Management API, e.g. https://yourorg.okta.com
# Optional. If unset, it is the scheme and host of OKTA_ISSUER. Must be https.
# OKTA_ORG_URL=https://your-org.okta.com
#
# Which Okta PROFILE attribute holds the value that matches users.username.
# Optional. By default it follows OKTA_IDENTITY_CLAIM: preferred_username reads
# profile.login, email reads profile.email, any other claim name reads the
# profile attribute of the same name. Set this only if your tenant builds the
# claim from a different attribute.
# OKTA_SYNC_PROFILE_ATTRIBUTE=login
# ── Email notifications (optional) ─────────────────────────────────────────────
# WP-assignment emails are OFF by default and are turned on from the Admin
# console (Notifications & email card), where the SMTP host/port/from-address