Repository navigation
Description
Summary
Tracking Epic consolidating all open Enterprise SSO + SCIM defects and improvements, to be validated end-to-end against a real Microsoft Entra ID tenant across every supported method (generic OIDC, generic OAuth2, Entra-native, SAML 2.0) plus SCIM 2.0 provisioning/de-provisioning.
The Enterprise SSO stack is a custom in-house implementation (not Better Auth's SSO plugin), in services/platform/convex/enterprise_sso/, with SCIM in services/platform/convex/scim/. Public endpoints exercised by the IdP:
- OIDC / OAuth2:
POST /api/sso/discover,GET /api/sso/authorize,GET /api/sso/callback(IdP redirect URI),GET /api/sso/set-session - SAML 2.0:
GET /api/sso/saml/metadata,GET /api/sso/saml/login,POST /api/sso/saml/acs(IdP reply/ACS URL) - SCIM 2.0:
/scim/v2/{ServiceProviderConfig,ResourceTypes,Schemas,Users,Groups,…}(bearer-token, org resolved from token)
Adapters: entra_id/, generic_oidc/, oauth2/, plus SAML.
Consolidated scope
🔴 Security (P1)
- Bug: SCIM POST /Users for an email owned by another org grafts a cross-tenant membership and renames that user #2036 — SCIM
POST /Usersfor an email owned by another org grafts a cross-tenant membership and renames that user - Bug: Open redirect on the trusted-headers authenticate endpoint (?redirect= reflected into navigation with no origin validation) #2037 — Open redirect on the trusted-headers authenticate endpoint (
?redirect=reflected with no origin validation)
🟠 Correctness (P2)
- Bug: OIDC/OAuth2 SSO login ignores the user's email and always routes to the first enabled connection (multi-org IdP collision) #2082 — OIDC/OAuth2 SSO login ignores the user's email and always routes to the first enabled connection (multi-org IdP collision)
- Bug: Switching a configured SSO connection's protocol with a blank Client secret passes client validation, then the backend throws an untranslated raw Error #2057 — Switching a configured connection's protocol with a blank Client secret passes client validation, then the backend throws an untranslated raw
Error
🟡 UX / hardening (P3)
- Bug: Enterprise SSO settings form logs React uncontrolled→controlled warnings (Select + Switch initialized undefined) #2095 — Enterprise SSO settings form logs React uncontrolled→controlled warnings (Select + Switch initialized
undefined) - Improvement: Standardize client-facing backend failures on ConvexError (sweep raw
throw new Erroracross auth/SSO/tasks/conversations/project-metrics) #2049 — Standardize client-facing backend failures onConvexError(sweep rawthrow new Erroracross auth/SSO/tasks/conversations/project-metrics) - Improvement: Auth/2FA/SSO low-severity correctness & UX gaps (enroll-wall guard, banner role, dead path guard, role-mapping toggle, SCIM PATCH, enforced-2FA disable) #2085 — Auth/2FA/SSO low-severity correctness & UX gaps (enroll-wall guard, banner role, dead-path guard, role-mapping toggle, SCIM PATCH, enforced-2FA disable)
🔵 Feature baseline
- Feature: SCIM 2.0 endpoint for automated user/group provisioning #1921 — SCIM 2.0 endpoint for automated user/group provisioning (verify completeness incl. de-provisioning under live Entra)
Plan
- Stand the stack up behind a public HTTPS tunnel (cloudflared),
SITE_URL= tunnel origin so all SSO callbacks/ACS/SCIM URLs are publicly reachable. - Configure a real Entra tenant: App registration(s) for OIDC + OAuth2, an Enterprise App for SAML, and SCIM provisioning.
- Run the E2E matrix below; post the full test report to this Epic.
- Fix every confirmed issue (code + i18n in all locales + co-located regression tests).
- Re-run unit + live E2E; open a PR linking every sub-issue + this Epic and drive CI green.
E2E test matrix
| Method | First-login provision | Role / team mapping | Session established | SCIM create | SCIM update | SCIM group | SCIM de-provision |
|---|---|---|---|---|---|---|---|
| Generic OIDC | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Generic OAuth2 | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Entra-native (group sync) | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| SAML 2.0 | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
Results filled in by the test report once the live run completes.
Test methodology: Playwright-driven Azure portal configuration + Playwright-driven Tale login flows, against a live Entra tenant over a cloudflared tunnel.
Activity
yannickmonney commentedon Jun 24, 2026
PR #2118 — consolidated fix
Fixed (Closes): #2036 (SCIM cross‑tenant graft → 409), #2037 (open redirect), #2082 (OIDC/OAuth2 email‑domain routing), #2057 (protocol‑switch secret + coded error), #2095 (controlled‑input warnings).
Partially addressed (Refs):
throw new Erroracross auth/SSO/tasks/conversations/project-metrics) #2049 — done for the SSO config + SCIM auth gates (sub‑item [09]); non‑SSO sites (users‑password [07], project‑metrics [51], tasks [58], conversations [84]) left for a focused follow‑up.role="status"), [06] (password‑expiry gate path), [13] (SCIM Group PATCH add+remove compose); deferred [04] enroll‑wall guard, [12] role‑mapping editor (a feature), [19] enforced‑2FA disable warning.Pending live validation: #1921 SCIM completeness + the end‑to‑end Entra OIDC / OAuth2 / Entra‑native / SAML + SCIM provisioning/de‑provisioning run against a real tenant (over a cloudflared tunnel). This is the final step; the full test report (filling in the matrix above) will be posted here.
Gate: typecheck · lint · format · knip · Opengrep SAST (0 findings) · 73,562 server/PII tests · 2,544 component/a11y tests — all green.
yannickmonney commentedon Jun 24, 2026
Update: PR #2118 now completes #2049 (all sites) and #2085 (all items, incl. a functional role-mapping-rules editor). All seven SSO/SCIM code issues are fixed; the full gate is green — 73,566 server + 2,545 component/a11y tests, Opengrep SAST 0 findings. Live Entra E2E remains the final step.
yannickmonney commentedon Jun 24, 2026
Enterprise SSO + SCIM — live end-to-end test report (Microsoft Entra)
Date: 2026-06-24 · Tenant:
tale.dev(629917cd-…) · Org: "SSO E2E Org" (jn785nxf8…)PR: #2118 · Branch:
fix/enterprise-sso-scim-hardeningMethod
521f2c51-…), tested over a public cloudflared tunnel so Entra reaches the live callback/SCIM endpoints on the local stack (Convex backend + Vite app).[email protected]with SMS MFA.curlreplaying the exact request shapes Azure's provisioning service sends (bearer token minted from the admin UI).Results by method
✅ OIDC (Entra-native,
entra-idadapter) — PASS, end-to-end[email protected]→ "Continue with SSO" → email→org discovery → Microsoft authorize → consent → callback → userinfo/me200 → user provisioned → landed in the org dashboard, signed in purely via SSO.User.Read(the org's scopes listed onlyopenid email profile offline_access). Sign-in failed after a successful token exchange.Fix (
c2bf8ea84):buildAuthorizeUrlalways ensureshttps://graph.microsoft.com/User.Read; the settings form's default Entra scope set lists it. Re-tested live → sign-in completes.✅ SCIM 2.0 provisioning/de-provisioning — PASS, comprehensive
Base
…/scim/v2, bearer auth, org resolved from the token row.GET /ServiceProviderConfig,/ResourceTypes,/SchemasPOST /Users(Azure payload)externalId+meta.locationcorrectGET /Users/{id},GET /Users?filter=userName eq "…"PATCHreplace attr / deactivate (active:false) / reactivatePOST /Groups,PATCHadd / path-filter remove / add+remove compose / replace / value-less remove-allDELETE /Users/{id}→GETPOST /Userswith an email owned by another org → 409uniqueness("belongs to another organization"); a brand-new email → 201 (no over-blocking).add+ value-less/path-filterremovecompose correctly in one request.DELETE /Userswas a soft-deactivate that returned 204 but the user stayed retrievable (GET 200) — violates RFC 7644 §3.6 and was inconsistent with Group DELETE.Fix (
d08946ec4): newdeprovisionUserremoves the membership + mirror + link → GET 404; Azure's primaryactive:falsesoft-disable path is unchanged (membership kept, restorable); the org owner is protected (DELETE owner → 403mutability, never orphan the org). PureclassifyDeprovision()unit-tested; re-validated live (DELETE 204 → GET 404; owner DELETE 403).✅ #2082 — login routes by email — PASS, live
/api/sso/discoverresolved[email protected]→ the correct org +oidc; the authorize URL carried[email protected]and the signedstatedecoded withorganizationId=jn785nxf8…. No more "always first connection".✅ #2085[12] — role-mapping editor — PASS, live
Toggling "Auto-assign roles from the IdP" reveals a real editor (Source = IdP group / app role / job title / claim → value → platform role). Added a rule and Saved; it persisted to the connection file as
{source:"group", pattern:"Tale-Admins", targetRole:"admin"},autoProvisionRole:true. The toggle is now functional, not a dead switch.✅ Graceful degradation — verified (code + live)
The callback fetches groups/app-roles only when role-mapping/team-sync need them, inside
try/catch→console.warnon failure. Enabling role-mapping withoutGroupMember.Read.Allconsent therefore does not break sign-in (the user simply matches no rule and keeps the default role).◻️ OAuth2 (generic) / SAML 2.0 / live group→team sync — not re-run live this session
These share the same provisioning core (
handleSsoLogin) and the same SCIM backend, both validated above, and their adapters are unit-tested. A full live run needs extra IdP setup beyond the OIDC app (a separate SAML Enterprise App + signing cert;GroupMember.Read.Alladmin consent + real Entra groups for live group sync). Can be run on request — the tunnel/app/admin session are ready.Prior fixes confirmed (carried by the PR)
#2036 ✓live · #2037 (sanitizeInternalRedirect, unit) · #2082 ✓live · #2057 (secret gate; OIDC secret preserved across edits, observed live) · #2095 (form renders with no controlled/uncontrolled warnings, observed live) · #2049 (SCIM 409 surfaced as a coded
ConvexError, observed live) · #2085 [04][05][06][12]✓live[13]✓live[19] · #1921 ✓live (SCIM completeness incl. de-provisioning)New fixes this session
c2bf8ea84— request GraphUser.Readfor Entra userinfo (OIDC 403 → fixed).d08946ec4— SCIM DELETE de-provisions (RFC 7644) + owner guard.d8e136e3c— (CI) reformat a main-side workflow JSON for oxfmt 0.44.0 so the merge check is green.Gate
typecheck ✓ · oxlint 0/0 ✓ · oxfmt ✓ · knip ✓ · opengrep 0 findings ✓ · server vitest 6362 ✓ · jsdom ✓ · pii ✓
yannickmonney commentedon Jun 24, 2026
Live E2E — expanded results (round 2)
Continued the live run against the real Entra tenant. Three more methods validated end-to-end, and a third defect found + fixed.
✅ OAuth2 (generic adapter) — PASS, live
Switched the connection to
protocol: oauth2pointed at Entra's OAuth2 endpoints (/oauth2/v2.0/authorize+/token) with userinfo athttps://graph.microsoft.com/oidc/userinfo.[email protected]signed in end-to-end via the userinfo endpoint path (no id_token) → session created, landed in the org. The protocol-switch correctly re-required the client secret (the #2057 gate).✅ Entra-native group → team sync — PASS, live
Added
https://graph.microsoft.com/GroupMember.Read.Allto the connection scopes + enabled "Sync IdP groups to teams". On login Microsoft prompted org consent for "Read group memberships" (admin-consented).getGroups(Graph/me/memberOf) returned ym's three Entra groups (Claude Code, Billing, All Company); the sync created a team for each and added ym to them.✅ Role mapping application — PASS, live (after a fix)
🐞 Found & fixed: "Auto-assign roles from the IdP" only set a member's role at first provision.
findOrCreateSsoUsercomputed the IdP-mapped role but, for an existing membership, discarded it — so an IdP promotion/demotion never propagated (stale-role correctness + security gap).Fix (
210e69958):handle_sso_loginpassessyncRole = autoProvisionRole; the mutation re-applies the mapped role to an existing membership each login (owner never touched; no-op writes skipped; new pureshouldSyncMemberRole, unit-tested).Verified live: a rule
All Company → adminwith ym in that group left ym asmemberbefore the fix; after the fix the next login promoted ym toadmin.✅ SAML 2.0 — SP side validated live; IdP round-trip in progress
https://sts.windows.net/{tenant}/, SSO…/saml2, signing cert).EntityDescriptor(ACS + entityID +WantAssertionsSigned)./api/sso/saml/login→ 302 to Entra/saml2withSAMLRequest+RelayState.saml/validate_assertion,saml/attributes.)Net new fixes this round
210e69958— re-sync the IdP-mapped role to existing SSO members each login.Running tally of defects found by the live run: User.Read userinfo 403, SCIM DELETE non-conformance + owner guard, role-mapping not updating existing members — all fixed, unit-tested, and on the PR with CI green.
yannickmonney commentedon Jun 24, 2026
Live E2E — remaining methods completed (full matrix now green)
Following the OIDC + SCIM report above, the remaining sign-in methods were validated live against the same real Microsoft Entra tenant. All four protocols + SCIM are now confirmed end-to-end, and the run surfaced one more defect (fixed).
✅ OAuth2 (generic adapter) — PASS, live
Switched the connection to
protocol: oauth2pointed at Entra's OAuth2 endpoints (/oauth2/v2.0/authorize,/token) with userinfo athttps://graph.microsoft.com/oidc/userinfo. Sign-in completed the full code→token→userinfo flow (no id_token) and landed a provisioned[email protected]session. Confirms the generic-OAuth2 path (distinct from entra-id's Graph/me).✅ Entra-native group→team sync + role mapping — PASS, live
Added the
GroupMember.Read.Allscope (admin-consented through the login), enabled "Sync IdP groups to teams", and signed in:getGroupsreturned ym's real Entra groups (Claude Code, Billing, All Company) and the sync created the matching teams and added ym to them. Role mapping (All Company → admin) then promoted ym — which exposed the bug below.🐞 Found & fixed — IdP role mapping never updated existing members
findOrCreateSsoUserset the mapped role only when it created a membership; for a returning user it computed the role and discarded it. So "auto-assign roles from the IdP" only worked on a user's first login — promotions/demotions never propagated (a stale-elevated-role correctness + security gap). Fixed so the mapped role re-applies on every login when auto-assign is on (owner protected, no-op writes skipped; new pureshouldSyncMemberRoleunit-tested). Verified live: with the fix, ym's re-login promotedmember → admin.✅ SAML 2.0 — PASS, live end-to-end
Created a SAML Enterprise App in Entra (SP Identifier + ACS Reply URL = Tale's SP metadata/ACS,
ymassigned), and configured the Tale SAML connection with the app-specific signing certificate. SP-initiated login (/api/sso/saml/login→AuthnRequest→ Entra/saml2→ signed assertion →POST /api/sso/saml/acs) validated the signature, provisioned the user, and created a SAML session — landed in the org dashboard.Net
Every supported method — OIDC, OAuth2, Entra-native (group sync + role mapping), SAML 2.0 — plus SCIM 2.0 is validated live against a real Entra tenant. Three defects were found and fixed across the run (Graph
User.Read, SCIMDELETEde-provisioning + owner guard, IdP role re-sync), all on PR #2118 with the full gate + CI green.fix(platform): Enterprise SSO + SCIM end-to-end hardening (Microsoft …