Authentication
OpenFinance uses BetterAuth for authentication. It supports email/password sign-up and optional Google OAuth.Auth Endpoints
BetterAuth exposes its endpoints under/api/auth/. The main endpoints are:
| Endpoint | Method | Description |
|---|---|---|
/api/auth/sign-up/email | POST | Create a new account with email and password |
/api/auth/sign-in/email | POST | Sign in with email and password |
/api/auth/sign-out | POST | Sign out and invalidate the session |
/api/auth/get-session | GET | Get the current session and user info |
/api/auth/sign-in/social | POST | Initiate Google OAuth sign-in (if configured) |
Session Management
When a user signs in, BetterAuth creates a session stored in the database and sets a session cookie in the browser. Session configuration:| Setting | Value |
|---|---|
| Session duration | 7 days |
| Session refresh | Every 24 hours |
| Cookie caching | Enabled (5 minute TTL) |
better-auth.session_token cookie. All authenticated API requests must include this cookie.
Sign Up
Create a new account by sending a POST request:- Minimum 8 characters
- Maximum 128 characters