Skip to content

TIP

This page mirrors packages/auth/README.md from the repository. Edit it at the source, not here.

@saasweave/auth

Better Auth configuration: sessions, organizations, admin plugin, 2FA, SSO, and platform access policy.

Always on

  • Email/password authentication
  • Organization plugin (multi-tenant workspaces, invitations, roles)
  • Admin plugin (platform role)
  • Session cookies with BETTER_AUTH_SECRET
  • Audit hooks → DB + outbound webhooks
  • Seat limit checks on invite/join
  • Signup policy (assertSignupsOpen)
  • Platform admin resolution (PLATFORM_ADMIN_EMAILS in production; first-user promotion in development only)

Optional plugins / env-gated

CapabilityEnabled when
Google OAuthGOOGLE_CLIENT_ID + secret
GitHub OAuthGITHUB_CLIENT_ID + secret
SSO / SAML (@better-auth/sso)Provider registered in console; feature flag sso
Two-factor (twoFactor plugin)User opts in on security page
Queued emailsREDIS_URL → BullMQ; else sync/log

Key exports

  • @saasweave/auth/index — configured auth instance
  • @saasweave/auth/public-providersgetPublicAuthProviderFlags() for /auth/providers

Environment variables

VariableNotes
BETTER_AUTH_SECRETMin 32 chars
VITE_WEB_URLAuth redirects
PLATFORM_ADMIN_EMAILSComma-separated
GOOGLE_*, GITHUB_*OAuth
REDIS_URLAsync email/notifications

Tests

bash
pnpm --filter @saasweave/auth test:unit

Released under the MIT License.