Repository navigation
test: prove SCIM-deprovisioned refusal at the signed SAML callback; fix member-removal-rejoin fixture - #4803
Conversation
…back too Extend scim-deprovisioned-sso-reprovision with a SAML lane: an ephemeral synthetic IdP (xml-crypto signed assertion, throwaway RSA key + self-signed cert) answers Den's AuthnRequest so both the OIDC and SAML callbacks are proven to refuse a SCIM-deactivated person with 403 and no ghost identity, and to leave the session table untouched. Timeout tightened to 120s per test.
The fixture inserted its organization row directly, so the org had no organization_role rows and normalizeAssignableRole fell back to "member" when the re-invited placeholder should have become "admin" (6/7 on clean dev). Seed the default roles like a real org and list the file in test:db.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Warden review summary — ClearNative findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (38894 ms), confidentiality-review (34788 ms), spec-provenance-review (120779 ms). Blockers
Advisories
Needs recheck
Observed review-thread metrics
Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority. |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (0f5bf02a80426cd436b369f68c06182749a55270). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Conflicts: ee/apps/den-api/package.json (scripts block: took dev's expanded "test" / "test:gateway-deployment" / "test:gateway-dashboard:db" scripts; this branch's member-removal-rejoin addition to "test:db" already landed on dev, so the result is identical to dev). evals/pnpm-lock.yaml merged cleanly and was re-verified with pnpm install --frozen-lockfile; [email protected] kept. Signed-off-by: Guillaume Loret <[email protected]>
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (073d4424c7943d8afcd216b8cbcac1b4f25bbff3). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Test evidence — a SCIM-deactivated member who tries SAML SSO is refused without a ghost identity, so the IdP can re-provision them (single-org Den) — ✅ passedSHA 073d442 · engine v1 ✅ passed · 3 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A SCIM-deprovisioned person is refused at the SAML callback without leaving a ghost identity (single_org)The signed SAML callback returned 403 "This user was deprovisioned by SCIM. Reactivate them in the identity provider before signing in." with no session cookie; afterwards the database holds 0 user row(s) and 0 session row(s) for [email protected], /v1/org lists no joined member for that email, and [email protected] remains owner.
ℹ️ ASSERTION — 2. The IdP's re-provision restores access after the refused SSO attempt (single_org)POST /Users for [email protected] returned 201 with id usr_01m28y848bec785361d2xph2p6; GET reports active=true, /v1/org lists the member as member, exactly 1 user row exists, password sign-in returned 403, and [email protected] is still owner.
ℹ️ ASSERTION — 3. SCIM deactivation removes direct access without disturbing other members or shared grants, and reprovision does not restore old grants (single_org)Before PATCH /Users active=false, all seven assignment types had a managed-member grant, a control-member grant, a team grant and a shared grant (role-scoped for desktop, org-wide otherwise). After HTTP 204, desktop/MCP direct rows were absent and marketplace/config/plugin/connector/dashboard direct rows remained with revocation timestamps. All 21 control/shared rows were unchanged, including grants created by the removed member. After POST /Users returned 201, every fixture resource's assignments exactly matched the post-deactivation snapshot, with no revived or copied grants.
Test run created 2026-09-11T19:13:40.266Z · Source: |
Test evidence — a SCIM-deactivated member who tries OIDC SSO is refused without a ghost identity, so the IdP can re-provision them (multi-org Den) — ✅ passedSHA 073d442 · engine v1 ✅ passed · 3 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A SCIM-deprovisioned person is refused at the OIDC callback without leaving a ghost identity (multi_org)The OIDC callback returned 403 "This user was deprovisioned by SCIM. Reactivate them in the identity provider before signing in." with no session cookie; afterwards the database holds 0 user row(s) and 0 session row(s) for [email protected], /v1/org lists no joined member for that email, and [email protected] remains member.
ℹ️ ASSERTION — 2. The IdP's re-provision restores access after the refused SSO attempt (multi_org)POST /Users for [email protected] returned 201 with id usr_01m28y6em6e258vjt6s3anrecm; GET reports active=true, /v1/org lists the member as member, exactly 1 user row exists, password sign-in returned 403, and [email protected] is still member.
ℹ️ ASSERTION — 3. SCIM deactivation removes direct access without disturbing other members or shared grants, and reprovision does not restore old grants (multi_org)Before PATCH /Users active=false, all seven assignment types had a managed-member grant, a control-member grant, a team grant and a shared grant (role-scoped for desktop, org-wide otherwise). After HTTP 204, desktop/MCP direct rows were absent and marketplace/config/plugin/connector/dashboard direct rows remained with revocation timestamps. All 21 control/shared rows were unchanged, including grants created by the removed member. After POST /Users returned 201, every fixture resource's assignments exactly matched the post-deactivation snapshot, with no revived or copied grants.
Test run created 2026-09-11T19:12:44.320Z · Source: |
Test evidence — a SCIM-deactivated member who tries OIDC SSO is refused without a ghost identity, so the IdP can re-provision them (single-org Den) — ✅ passedSHA 073d442 · engine v1 ✅ passed · 3 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A SCIM-deprovisioned person is refused at the OIDC callback without leaving a ghost identity (single_org)The OIDC callback returned 403 "This user was deprovisioned by SCIM. Reactivate them in the identity provider before signing in." with no session cookie; afterwards the database holds 0 user row(s) and 0 session row(s) for [email protected], /v1/org lists no joined member for that email, and [email protected] remains owner.
ℹ️ ASSERTION — 2. The IdP's re-provision restores access after the refused SSO attempt (single_org)POST /Users for [email protected] returned 201 with id usr_01m28y6zzdemg9t6y0k3fzcks9; GET reports active=true, /v1/org lists the member as member, exactly 1 user row exists, password sign-in returned 403, and [email protected] is still owner.
ℹ️ ASSERTION — 3. SCIM deactivation removes direct access without disturbing other members or shared grants, and reprovision does not restore old grants (single_org)Before PATCH /Users active=false, all seven assignment types had a managed-member grant, a control-member grant, a team grant and a shared grant (role-scoped for desktop, org-wide otherwise). After HTTP 204, desktop/MCP direct rows were absent and marketplace/config/plugin/connector/dashboard direct rows remained with revocation timestamps. All 21 control/shared rows were unchanged, including grants created by the removed member. After POST /Users returned 201, every fixture resource's assignments exactly matched the post-deactivation snapshot, with no revived or copied grants.
Test run created 2026-09-11T19:13:03.784Z · Source: |
Test evidence — a SCIM-deactivated member who tries SAML SSO is refused without a ghost identity, so the IdP can re-provision them (multi-org Den) — ✅ passedSHA 073d442 · engine v1 ✅ passed · 3 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A SCIM-deprovisioned person is refused at the SAML callback without leaving a ghost identity (multi_org)The signed SAML callback returned 403 "This user was deprovisioned by SCIM. Reactivate them in the identity provider before signing in." with no session cookie; afterwards the database holds 0 user row(s) and 0 session row(s) for [email protected], /v1/org lists no joined member for that email, and [email protected] remains member.
ℹ️ ASSERTION — 2. The IdP's re-provision restores access after the refused SSO attempt (multi_org)POST /Users for [email protected] returned 201 with id usr_01m28y7j8ae9690sraeqazr7ch; GET reports active=true, /v1/org lists the member as member, exactly 1 user row exists, password sign-in returned 403, and [email protected] is still member.
ℹ️ ASSERTION — 3. SCIM deactivation removes direct access without disturbing other members or shared grants, and reprovision does not restore old grants (multi_org)Before PATCH /Users active=false, all seven assignment types had a managed-member grant, a control-member grant, a team grant and a shared grant (role-scoped for desktop, org-wide otherwise). After HTTP 204, desktop/MCP direct rows were absent and marketplace/config/plugin/connector/dashboard direct rows remained with revocation timestamps. All 21 control/shared rows were unchanged, including grants created by the removed member. After POST /Users returned 201, every fixture resource's assignments exactly matched the post-deactivation snapshot, with no revived or copied grants.
Test run created 2026-09-11T19:13:21.484Z · Source: |
Re-proof after merging
|
| Command | Result |
|---|---|
pnpm evals:pr specs/scim-deprovisioned-sso-reprovision.test.ts |
exit 0 · 4 passed / 0 failed / 0 skipped (OIDC + SAML × multi-org + single-org), 74.9 s — 4 test-evidence comments above, all on SHA 073d4424c |
DATABASE_URL=mysql://root:[email protected]:3306/openwork_test pnpm --filter @openwork-ee/den-api test:db |
exit 0 · 10 pass / 0 fail across 3 files (member-removal-rejoin 8/8 alone; scim-provider-rotation, sso-provider-rotation) |
Note: the local openwork_test database predated the gateway tables from #4358 (now on dev) and the first test:db run failed 5/10 on Table 'openwork_test.gateway_provider_oauth_states' doesn't exist; the test DB was recreated with pnpm --filter @openwork-ee/den-db db:push and re-run green. This is a stale-fixture-DB artefact, not a code regression — CI prepares its own DB.
Coverage gap (unchanged from the PR body): test:db is a bun:test lane with no testkit evidence tape, so only counts are recorded here.
Test-only follow-up to #4775 (SCIM-deprovisioned SSO ghost). No product code is changed.
What
evals/specs/scim-deprovisioned-sso-reprovision.test.tsnow runs each org mode (multi-org, single-org) against both the OIDC callback and the SAML ACS. A new helperevals/specs/helpers/scim-saml-fixture.tsacts as a synthetic IdP: throwaway RSA key + 1-day self-signed cert, decodes Den'sAuthnRequest, and posts anxml-crypto-signed assertion to/sso/saml2/sp/acs/:providerId. The spec also asserts thesessiontable is byte-identical before/after the refused callback (no orphan session, not just none for that email). Per-test timeout tightened 600s → 120s.evals/package.jsonadds[email protected]; the lockfile diff is only that package and its transitive deps (+31 lines).ee/apps/den-api/test/member-removal-rejoin.test.ts— the org row was inserted directly, so it had noorganization_rolerows andnormalizeAssignableRole(ee/apps/den-api/src/orgs.ts:517-523, used at:760) fell back to"member"for the re-invited"admin"placeholder (6/7 on cleandev). The fixture now callsseedDefaultOrganizationRoleslikecreateOrganizationdoes (orgs.ts:1106,:1431). The file is added totest:dbso the DB lane actually covers it.Verification
Lane: local (Den cold-booted through
server(); MySQL at 127.0.0.1:3306). Runs are on the PR head0f5bf02a8.pnpm evals:pr specs/scim-deprovisioned-sso-reprovision.test.tsDATABASE_URL=mysql://root:[email protected]:3306/openwork_test pnpm --filter @openwork-ee/den-api test:dbbun test test/member-removal-rejoin.test.tson the pre-fix treeExpected "admin" Received "member"at l.263pnpm --dir evals typechecktsc -p .is red on baselinedevwith ~400 pre-existing unrelated errors (den-db schema resolution, email--jsx,.mjsdeclarations)Verdict: Passed — every claim has an observable assertion in the recorded runs. Evidence comment follows below.
Product follow-ups (not changed here — need a contract decision)
The signed-SAML run confirms the #4775 guard holds for both protocols. Three residual behaviours surfaced while writing it and are deliberately left as-is pending a decision:
usr_id.ee/apps/den-api/src/scim.ts:474-500— after the tombstone/identity transaction,shouldDeleteGlobalUser(activeMembershipCount === 0)callsdeleteGlobalAuthUser. The re-provisionPOST /Usersthen returns 201 with a fresh id; anything keyed on the old user id (sessions, connected accounts, member credentials) is gone. Decision: is identity continuity across deprovision→reprovision a requirement, or is "new user" the intended contract?scim.ts:497-500branch), and a laterPOST /Usersfor that email conflicts instead of reactivating the tombstoned identity. Decision: should re-provision of a tombstoned email in a retained user resolve to reactivation (200/201 with the existing id) rather than a uniqueness 409?user.create.beforehook (ee/apps/den-api/src/auth.ts:640-650) only fires on the new-user path. For a retained user, Better Auth has already inserted the session beforeprovisionUserthrowsFORBIDDEN(auth.ts:1395-1408), so the refusal is correct at the HTTP level but an orphan session row remains. Decision: move the deprovisioned check earlier in the SSO callback (before session creation) or explicitly revoke the session on refusal.The spec's new "session table unchanged" assertion currently passes because the journey only exercises the last-membership path (user deleted → new-user path). Extending it to a retained-user journey would make finding 3 red; that is intentionally not done until the contract is decided.