Authentication System
Budget Bee uses Better Auth with JWT (JSON Web Token) based authentication. The system supports multiple authentication methods including email/password and OAuth providers.Base URL
All authentication endpoints are available at:Authentication Methods
Budget Bee supports the following authentication methods:- Email/Password - Traditional email and password authentication
- Google OAuth - Sign in with Google
- Bearer Tokens - API access using JWT tokens
Session Management
Session Configuration
Sessions are stored in the database with the following fields:Unique session identifier
Reference to the authenticated user
Currently active organization for this session
When the session expires
IP address of the client
Browser/client user agent string
Session creation timestamp
Last session update timestamp
JWT Token Structure
Token Payload
JWT tokens issued by Budget Bee contain the following claims:Subject - the user ID
User identifier (same as sub)
Always “authenticated” for logged-in users
User’s email address
Active organization ID (if any)
User’s role in the organization:
owner, admin, editor, or viewerCurrent subscription information
Token issuer
Token audience
Expiration timestamp (1 hour from issue)
Making Authenticated Requests
Using Bearer Token
Include the JWT token in theAuthorization header:
Using Cookies
For browser-based requests, sessions are automatically managed via secure HTTP-only cookies.Email Verification
Requirements
- Email verification is required for all new accounts
- Verification emails are sent on sign-up and sign-in (if not verified)
- Unverified users cannot create organizations
Verification Flow
- User signs up with email/password
- Verification email sent with unique link
- User clicks link to verify email
- Account becomes fully active
Security Features
Password Reset
Secure password reset flow with email verification:- Reset link expires after configured time
- One-time use tokens
- Email notification on password change
Account Linking
Trusted providers (Google) can be linked to existing accounts:- Prevents duplicate accounts
- Seamless provider switching
- Maintains single user identity
Database Roles
Budget Bee uses PostgreSQL row-level security (RLS) with specific roles:anon- Anonymous/unauthenticated accessauthenticated- Logged-in usersauth_admin- Special role for auth operationssubscription_admin- Subscription management operations
Next Steps
Email/Password Auth
Learn about email/password authentication endpoints
OAuth Setup
Configure Google OAuth authentication

