Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
Implementation Plan: SSO Domain Verification (DNS TXT)
Spec: .ai/specs/2026-08-27-sso-domain-verification.md
Branch: sso-implementation-research (feature branch, unmerged — migration edited in place)
Key design point discovered during grounding: the connection lookups
(getSsoConnection, getSsoConnectionByDomain, getSsoConnectionByProviderId)
will attach a computed domains: string[] (VERIFIED domains only) to their
returned row, so every downstream consumer — ERP/MES callback .includes
check, uncoveredSsoDomainError, getSsoInviteDomainError — keeps its exact
shape and needs no change.
Tasks
-
- Edit
packages/database/supabase/migrations/20260820215433_sso-connection.sql: dropdomains TEXT[]+ GIN index fromssoConnection; addssoDomaintable (id('ssod'), companyId, connectionId, domain, verificationToken, status pending|verified CHECK, verifiedAt, audit cols, composite PK, composite FK → ssoConnection ON DELETE CASCADE, global UNIQUE(domain), indexes, 4 RLS policies mirroring ssoConnection). Verify: SQL reviewed; applied to dev DB via user-run delta (end of plan).
- Edit
-
packages/ee/src/sso/verification.server.ts(new): token generation,getTxtRecord,checkDomainVerification(pinned resolvers, discriminated result, never throws). +verification.server.test.ts(mocknode:dns/promises). Verify:pnpm --filter @carbon/ee test.
-
- Rework
packages/ee/src/sso/connections.server.ts: lookups embedssoDomainand attach verifieddomains;upsertSsoConnectiondrops domains handling (steal check deleted — DB UNIQUE owns it); newgetSsoDomains,addSsoDomain,verifySsoDomain,removeSsoDomain+ internalsyncGoTrueDomains. Export viaindex.server.ts. Updatesso.server.test.ts. Verify:pnpm --filter @carbon/ee test+ typecheck.
- Rework
-
apps/erp/app/modules/settings/settings.models.ts: removedomainsfromssoConnectionValidator; addssoDomainValidator+PUBLIC_EMAIL_DOMAINS; updatesettings.models.sso.test.ts. Verify:pnpm --filter erp test -- settings.models.sso(or vitest path run).
-
apps/erp/app/routes/x+/settings+/sso.tsx:addDomain/verifyDomain/removeDomainintents (reason-specific verify errors).
-
apps/erp/app/routes/x+/settings+/security.tsx: remove domains input from IdP form; add Email Domains card (list + status badge + TXT instructions + Verify/Remove + add form); requireSso hint when zero verified.
-
- Callbacks + invite paths: no code change needed (shape preserved) — re-read to confirm; MES same.
-
- Docs + docs-sync:
docs/content/docs/platform/single-sign-on.mdx+ agent-KB mirror;.claude/rules/authentication-system.mdSSO section;packages/ee/AGENTS.md; spec changelog.
- Docs + docs-sync:
-
- Validation: regenerate types after user applies DB delta;
pnpm exec turbo run typecheck --filter=@carbon/ee --filter=erp --filter=mes;pnpm run lint;pnpm --filter @carbon/ee test.
- Validation: regenerate types after user applies DB delta;
DB delta for already-applied dev DBs (user-run)
DROP INDEX IF EXISTS "ssoConnection_domains_idx";
ALTER TABLE "ssoConnection" DROP COLUMN IF EXISTS "domains";
-- then the ssoDomain CREATE TABLE + indexes + RLS block from the edited migration
Build-time verifications
- GoTrue admin API accepts
domains: []on create (assumed from GoTrue source; runtime-verified by the user's carbon.ms test). Fallback if refused: create provider lazily at first verification (providerId nullable) — NOT implemented unless needed.