Skip to content

feat(api): enterprise SSO (SAML/OIDC) and SCIM provisioning - #2721

Open
Makisuo wants to merge 13 commits into
mainfrom
t3/enterprise-sso-scim
Open

Makisuo wants to merge 13 commits into
mainfrom
t3/enterprise-sso-scim

fix(api): the connection scan advances by the rows Clerk returned

12792c3
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 16, 2026 in 33s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. Only the gateway scan delta changed since the last review; its offset logic and fail-closed branches are pinned by two tests, but the head's CI checks are still queued.
no findings · tests covered · risk high · 1/1 new units observable

Re-review of the two files changed since 0475734: scanClaimedDomains now advances Clerk's offset by the rows each page actually returned, with tests for short and empty pages. Safe to merge. It does not address the McpOAuthProtocolError seen from apps/api/src/runtime/http-graph.ts.

  • scanClaimedDomains advances its offset by the rows Clerk returned, not by the page limit
  • Short-page and empty-page scans still fail closed with ClerkRequestError

Before merge

Production impact

Open errors in the changed files (1)
Issue Service Occurrences File
@maple/backend/errors/McpOAuthProtocolError maple-api 4 apps/api/src/runtime/http-graph.ts

After this merges, Maple checks whether they stop.

Production traffic of the changed files (last 7 days)
File Calls/day Busiest operations
packages/backend/src/services/org/enterprise-sso/ClerkSsoGateway.ts 6.0k POST 2.9k/day, 0.1% err
Clerk.organizations.getOrganizationMembershipList 1.3k/day, 0.0% err
POST 1.2k/day, 0.1% err
Telemetry this change adds and removes (30)
  • ➕ span name HttpEnterpriseSso.get · apps/api/src/routes/internal/enterprise-sso.http.ts:31
  • ➕ span name HttpEnterpriseSso.addDomain · apps/api/src/routes/internal/enterprise-sso.http.ts:42
  • ➕ span name HttpEnterpriseSso.verifyDomain · apps/api/src/routes/internal/enterprise-sso.http.ts:52
  • ➕ span name HttpEnterpriseSso.removeDomain · apps/api/src/routes/internal/enterprise-sso.http.ts:62
  • ➕ span name HttpEnterpriseSso.createConnection · apps/api/src/routes/internal/enterprise-sso.http.ts:76
  • ➕ span name HttpEnterpriseSso.updateConnection · apps/api/src/routes/internal/enterprise-sso.http.ts:90
  • ➕ span name HttpEnterpriseSso.setEnforcement · apps/api/src/routes/internal/enterprise-sso.http.ts:102
  • ➕ span name HttpEnterpriseSso.deleteConnection · apps/api/src/routes/internal/enterprise-sso.http.ts:110
  • ➕ span name HttpEnterpriseSso.createDirectory · apps/api/src/routes/internal/enterprise-sso.http.ts:118
  • ➕ span name HttpEnterpriseSso.rotateDirectoryToken · apps/api/src/routes/internal/enterprise-sso.http.ts:126
  • ➕ span name HttpEnterpriseSso.setDirectoryState · apps/api/src/routes/internal/enterprise-sso.http.ts:138
  • ➕ span name HttpEnterpriseSso.deleteDirectory · apps/api/src/routes/internal/enterprise-sso.http.ts:146
  • ➕ span name HttpEnterpriseSso.setRoleMappings · apps/api/src/routes/internal/enterprise-sso.http.ts:161
  • ➕ span name HttpEnterpriseSso.addBypassUser · apps/api/src/routes/internal/enterprise-sso.http.ts:169
  • ➕ span name HttpEnterpriseSso.removeBypassUser · apps/api/src/routes/internal/enterprise-sso.http.ts:177
  • ➕ attribute maple.webhook.deprovisioned · apps/api/src/routes/webhooks/clerk.http.ts:248
  • ➕ span name DnsTxtResolver.lookupTxt · packages/backend/src/services/org/enterprise-sso/DnsTxtResolver.ts:36
  • ➕ attribute dns.question.name · packages/backend/src/services/org/enterprise-sso/DnsTxtResolver.ts:37
  • ➕ span name DNS-over-HTTPS TXT · packages/backend/src/services/org/enterprise-sso/DnsTxtResolver.ts:53
  • ➕ span name EnterpriseSsoService.requireEntitled · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:256
  • ➕ span name EnterpriseSsoService.get · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:361
  • ➕ span name EnterpriseSsoService.addDomain · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:458
  • ➕ attribute maple.sso.domain · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:465
  • ➕ span name EnterpriseSsoService.verifyDomain · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:507
  • ➕ attribute maple.sso.txt_records · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:524
  • ➕ span name EnterpriseSsoService.removeDomain · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:545
  • ➕ span name EnterpriseSsoService.connectionInput · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:574
  • ➕ span name EnterpriseSsoService.createConnection · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:628
  • ➕ attribute maple.sso.provider · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:634
  • ➕ span name EnterpriseSsoService.updateConnection · packages/backend/src/services/org/enterprise-sso/EnterpriseSsoService.ts:669
What was checked
  • Offset advance pinned at 0/50/100 by the new short-page test (ClerkSsoGateway.test.ts:48)
  • Empty page and exhausted page budget both fail closed (ClerkSsoGateway.ts:131)
  • Scan terminates: page + 1 >= maxPages bounds it at 100 Clerk calls
Observability coverage: 1 of 1 changes observable
Change Kind Observable Evidence
Clerk enterprise connection scan (Clerk.enterpriseConnections.list) outbound call yes sdk at ClerkSsoGateway.ts:492 goes through clerkRequest, and raw calls carry a client span with peer.service: clerk (ClerkSsoGateway.ts:379)

12792c3 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.