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
Enterprise SSO for Carbon — Research Findings
Date: 2026-08-21. Researched: current Carbon auth integration points (code-verified) + Supabase/GoTrue SSO capabilities (web-verified, sources at bottom).
Current state in Carbon
- No SSO/SAML/OIDC scaffolding exists — zero matches for
signInWithSSO,saml,sso_provider,workosin app code. - Auth is Supabase GoTrue (
supabase/gotrue:v2.189.0in both dev and prod compose) with magic link, Google + Azure OAuth (signInWithOAuth), passkeys, TOTP MFA, cookie sessions. - The callback flow is provider-agnostic:
_public+/callback.tsxconsumes any Supabase session (refresh token POSTed to the action →refreshAccessToken→carboncookie, with the MFA park-and-challenge gate). A new SSO method that yields a GoTrue session needs no callback changes. - Provider gating:
AuthProvidertype (packages/env/src/index.ts:116—"email" | "google" | "azure" | "passkey") +AUTH_PROVIDERSenv +isAuthProviderEnabled(), consumed by ERP/MES login pages, unlock,x+/_layout, account security. - Provisioning:
create_public_user()trigger createspublic.user+userPermissionfor any newauth.usersrow, but notuserToCompany. Company attachment happens via invite (acceptInvite→addUserToCompany+ permissions) or self-serve verify → onboarding (blocked entirely in Enterprise edition,login.tsx:229). A zero-company user gets forced into onboarding byx+/_layout.tsx. - Per-company config pattern available:
integrationcatalog +companyIntegration.metadata(jsonschema-validated), secrets in Supabase vault (post-NIST migration20260817123719).
Supabase options (Aug 2026)
- Native SAML 2.0 (recommended):
supabase.auth.signInWithSSO({ domain })→ redirect URL → IdP → GoTrue session → existing/callback. Providers registered per-IdP with adomainsarray via CLI (supabase sso add) / Management API (hosted) or GoTrue admin RESTPOST /auth/v1/admin/sso/providerswith service-role key (self-hosted, no restart needed). Hosted: Pro plan+, 50 SSO MAU included then $0.015/MAU. Self-hosted:GOTRUE_SAML_ENABLED=true+GOTRUE_SAML_PRIVATE_KEY(base64 PKCS#1 DER, not PKCS#8 — the #1 gotcha), SP metadata at/sso/saml/metadata, ACS at/sso/saml/acs(gateway routes must be open/no key-auth). Attribute mapping JSON → JWT claims +identity_data; assertion must contain email.sso_provider_idlands in the JWT (usable in RLS). SSO identities are deliberately never linked to existing accounts. - Custom OIDC providers (launched Apr 2026):
signInWithOAuth({ provider: "custom:okta-acme" }), issuer-URL discovery, dashboard/admin-API config. Free = 3 providers, Pro+ = unlimited. Self-hosted support unverified — self-hosted docs still only documentGOTRUE_EXTERNAL_<PROVIDER>_*env vars; verify against supabase/auth release notes before relying on it. - Azure single-tenant: existing
azureprovider accepts a tenant-specific URL (https://login.microsoftonline.com/<tenant-id>) — cheapest path if the only ask is "log in with our Entra". Watch thexms_edovunverified-email-domain claim. - Brokers: WorkOS (first-party Supabase docs but replaces GoTrue session issuance — clashes with Carbon's cookie/MFA/passkey stack), Ory Polis (ex-BoxyHQ Jackson; self-hostable SAML→OIDC bridge + SCIM 2.0), SSOReady (API middleware, you mint sessions yourself). Only needed if SCIM is a requirement — Supabase Auth has no SCIM as of mid-2026.
Recommended approach: native GoTrue SAML
Works identically on self-hosted Docker and hosted Supabase (same GoTrue code), keeps one session system (cookie, MFA gate, claims cache all untouched).
Change points:
- GoTrue config:
packages/dev/docker/docker-compose.dev.yml+contrib/deploying/simple-docker-caddy/docker-compose.prod.yml— addGOTRUE_SAML_ENABLED+GOTRUE_SAML_PRIVATE_KEY(per-env secret); mirror inconfig.tomlfor hosted parity; SST/managed path configures the Supabase project instead. Verify the dev/prod gateway exposes/auth/v1/sso/saml/{metadata,acs}unauthenticated. packages/env/src/index.ts: add"sso"toAuthProvider(L116); include inAUTH_PROVIDERS.- Login pages (ERP
_public+/login.tsx, MES mirror): gated "Continue with SSO" — take the already-entered email, callcarbonClient.auth.signInWithSSO({ domain, options: { redirectTo: /callback } }), redirect to the returned URL. Callback: no changes. - Provider registration: per-customer-IdP via GoTrue admin API. Optionally an admin settings UI storing non-secret IdP metadata via the
integration/companyIntegration+ vault pattern; note providers are global to the GoTrue project — thedomainsarray is the actual tenant router, and a domain can belong to only one provider. - Provisioning decision (the real design question): SAML JIT-creates
auth.users(trigger gives identity, not membership). Options: (a) invite-first — SSO user must have a pending/accepted invite, else "User not found" at callback; (b) JIT-attach — map SSO domain → companyId and auto-addUserToCompanywith default permissions. Enterprise edition currently blocks unknown users only on the magic-link path — SAML bypasses that check, so the chosen policy must be enforced at callback or via a before-user-created Auth Hook. - Optional domain enforcement: block magic link/OAuth for SSO-managed domains via an app-side check in the login action (no native GoTrue enforcement exists).
Key challenges (assessed 2026-08-21)
- Existing-user migration: SSO identities never link to existing accounts — an existing user signing in via SAML gets a NEW
auth.usersid;userToCompany/permissions/audit keyed to the old id, andcreate_public_userwill collide on the duplicate email. Needs a designed reconciliation or re-invite contract. - Enterprise bypass: the "reject unknown users" check lives only on the magic-link login path; SAML JIT-creation bypasses it. Enforce invite-first/JIT policy at callback or via an Auth Hook, else registered-IdP users get orphaned Carbon accounts.
- Asserted-email trust (VERIFY): unconfirmed whether GoTrue restricts assertion emails to the provider's registered domains. If not, a customer IdP could assert another company's domain — dangerous combined with any email-based reconciliation for #1.
- Tenancy mismatch: providers are project-global;
domainsis the only router and a domain maps to one provider. Shared parent-org domains, contractors, multi-company users need an explicit domain→provider→company mapping table. - Hosted vs self-hosted ops split: self-hosted registers providers via GoTrue admin REST (automatable in-app); hosted goes through the Supabase Management API/CLI (personal access token, Pro plan) — an in-app SSO settings screen behaves differently per mode.
- MFA interplay: SSO users get double-MFA'd by Carbon TOTP;
CONTROLLED_ENVIRONMENTforces requireMfa (NIST 3.5.3), so any SSO exemption there needs a compliance rationale. - No SCIM / no SLO: IdP offboarding doesn't propagate; 7-day cookie keeps refreshing. v1 answer is manual deactivation (existing flows); Ory Polis/SSOReady are the later SCIM path.
- Dev/test story: IdP must POST to the ACS URL — needs a mock SAML IdP container in dev compose; verify gateways expose
/auth/v1/sso/saml/{acs,metadata}unauthenticated (prod Caddy compose was not configured for this). - Smaller: domain enforcement must also cover Google/Azure/passkey buttons; invite flow sends magic links (contradicts SSO-only domains); attribute mapping must satisfy
create_public_username-splitting; PKCS#1 key in Swarm secrets; IdP cert rotation; academy/starter hardcode login buttons.
Decisions (Naveen, 2026-08-21)
- Scope: full SAML SSO in addition to the existing Google/Azure buttons — they coexist; SSO activates per registered email domain.
- Deployment target: self-hosted first — provider registration via GoTrue admin REST with the service-role key (no Supabase plan/Management API dependency).
- Provisioning: invite-first for v1 (reuses
acceptInvitemachinery, closes the Enterprise JIT bypass, no default-permissions design). JIT-attach deferred as a possible per-company toggle. - Migration contract: "enabling SSO means your users get re-invited" — new SSO identity attached via invite. No id-remap migration in v1.
- First-SSO-login migration (one atomic transaction): on a migrated user's first SSO login — (1) invite attaches new account with permissions, (2) all assignable/mutable references (assignees on open tasks, work orders, jobs, approvals) are automatically re-pointed from the old account (matched by email + company) to the new one, (3) old account deactivated in the same transaction (sessions invalidated, magic link dead, TOTP moot). Immutable audit fields (
createdByetc.) deliberately stay on the deactivated old account — same name/email so display is unchanged; audit trails are never rewritten. Deactivating-before-settling also gives the duplicate-email trigger collision a defined ordering. - Edition gating: SSO is Enterprise-only (
CarbonEdition === Edition.Enterprisegates the login button + settings screen). - MFA policy: trust the IdP — skip Carbon TOTP for sessions bearing
sso_provider_id, EXCEPT underCONTROLLED_ENVIRONMENT=true, where forced TOTP remains (NIST 800-171 3.5.3 needs attestable MFA). - Admin UX: in-app Settings → SSO screen (Enterprise-gated): IdP metadata URL/XML + domains in, ACS + SP metadata URLs displayed out; server calls GoTrue admin API. Largest UI chunk of the project.
Remaining open items
- Verify whether GoTrue restricts SAML-asserted emails to the provider's registered domains (challenge #3) — check supabase/auth source.
- Mock SAML IdP container for dev compose + gateway routes for
/auth/v1/sso/saml/{acs,metadata}. - Invite flow for SSO-managed domains currently sends magic links — needs an SSO-aware invite path.
- Whether to enforce SSO-only (block magic link/OAuth/passkey) for managed domains in v1.
Sources
Supabase SAML SSO · Self-hosted SAML · Pricing · Custom OAuth/OIDC · Custom OIDC blog · Azure provider · WorkOS third-party · Ory Polis · SSOReady · Self-hosted walkthrough