Auth and organizations
Better Auth powers sessions, organizations, enterprise SSO, SCIM, API keys, OAuth, and 2FA.
Fabric Experiments uses Better Auth through packages/auth and apps/api/src/server/auth.ts.
Enabled capabilities:
- email/password with required verification,
- magic links,
- Google and GitHub OAuth when env vars are present,
- organization plugin,
- API keys with rate limits,
- admin plugin,
- two-factor auth,
- enterprise SAML 2.0 and OIDC SSO,
- organization provisioning on enterprise sign-in,
- SCIM 2.0 user provisioning with hashed provider tokens.
The login page discovers enterprise SSO from the user's work email. SAML assertions require timestamps, SHA-1/deprecated cryptographic algorithms are rejected, InResponseTo/replay validation is enabled, IdP-initiated unsolicited responses are disabled, and clock skew is limited to two minutes. SCIM token creation is organization-scoped and restricted to owners/admins; linking an unrelated pre-existing user by email is disabled.
The database contract for these plugins is in
016_enterprise_identity.sql. SSO/SCIM configuration should be validated with
the customer's identity provider in staging before enforcing SSO for an org.
Important env vars
DATABASE_URLBETTER_AUTH_SECRETFX_BASE_URLFX_TRUSTED_ORIGINSRESEND_API_KEYandRESEND_FROMfor real email deliveryFX_EMAIL_TRANSPORT=logonly for disposable integration environments where verification messages must be captured by a test runnerGOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRETGITHUB_CLIENT_ID/GITHUB_CLIENT_SECRET
Development logs verification messages when no provider is configured.
Production fails closed without RESEND_API_KEY; the explicit log transport
exists for disposable browser-test stacks and must not be enabled in a
customer environment because verification links are credentials.