ShipFree uses Better-Auth for a complete authentication solution with support for email/password, OAuth providers, email OTP, and organizations.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/revokslab/shipfree/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
The authentication system consists of three main components:- Server-side Auth Configuration (
src/lib/auth/auth.ts) - Client-side Auth Client (
src/lib/auth/auth-client.ts) - API Routes (
src/app/api/auth/[...all]/route.ts)
Features
Email & Password Authentication
Email and password authentication with optional email verification:Email OTP (One-Time Password)
Passwordless authentication via email OTP:src/lib/auth/auth.ts:130-188):
- OTP Length: 6 digits
- Expiration: 15 minutes
- Types:
sign-in,email-verification,forget-password - Email delivery: Configured via email service (Resend, Postmark, Plunk, or Nodemailer)
OAuth Providers
Supported OAuth providers (configured insrc/lib/auth/auth.ts:45-78):
Requires
GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRETGitHub
Requires
GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRETMicrosoft
Requires
MICROSOFT_CLIENT_ID and MICROSOFT_CLIENT_SECRETRequires
FACEBOOK_CLIENT_ID and FACEBOOK_CLIENT_SECRETSession Management
Configuration fromsrc/lib/auth/auth.ts:35-43:
Enable cookie-based session caching
Cache duration: 24 hours (in seconds)
Session lifetime: 30 days (in seconds)
How often to refresh expiry: 24 hours (in seconds)
Fresh session window: 1 hour (in seconds)
Organizations
Multi-tenant organization support via the organization plugin (src/lib/auth/auth.ts:190-211):
Database Schema
Better-Auth integrates with ShipFree’s PostgreSQL database via Drizzle ORM. See Database Schema for table structures. Key tables:user- User accountssession- Active sessionsaccount- OAuth accounts linked to usersverification- Email verification tokens and OTP codes
Email Verification
Email verification can be enabled/disabled via feature flag (src/config/feature-flags.ts).
Configuration (src/lib/auth/auth.ts:80-126):
Password Reset
Password reset flow:Sign Out
Custom Pages
Authentication pages are configured insrc/lib/auth/auth.ts:214-219:
Next Steps
API Endpoints
Explore all available authentication endpoints
Database Schema
View authentication-related database tables