Skip to main content

Configuration

Complete reference for all environment variables and configuration options.

Required Variables

These must be set for the application to function:

VariableDescriptionExample
DATABASE_URLPostgreSQL connection stringpostgresql://user:pass@host:5432/dbname
JWT_SECRET_KEYJWT signing key for authenticationopenssl rand -hex 32
FLASK_SECRET_KEYSession encryption key (fallback for JWT if not set)openssl rand -hex 32
Production Requirement

In production, at least one of JWT_SECRET_KEY or FLASK_SECRET_KEY must be explicitly set. The application will fail to start otherwise to prevent insecure deployments.

Deployment Options

VariableDescriptionDefault
DEPLOYMENT_MODEself-hosted or saasself-hosted
ENABLE_REGISTRATIONAllow public user registrationfalse
REQUIRE_EMAIL_VERIFICATIONRequire email verification for new usersfalse

Language, Currency, and Mobile Compatibility

VariableDescriptionDefault
DEFAULT_LOCALEBCP 47 locale used for deployment-level number and date formattingen-US
MINIMUM_MOBILE_VERSIONOptional minimum compatible mobile client version advertised by the serverUnset
OAUTH_REDIRECT_URISAdditional comma-separated OAuth callback URIs, such as development-client or universal linksUnset

Currency is now a per-user setting selected in the web or mobile Settings screen. New users begin with USD and may choose from USD, EUR, JPY, GBP, CNY, CHF, AUD, CAD, HKD, SGD, INR, KRW, SEK, NZD, and MXN.

DEFAULT_CURRENCY is no longer a runtime setting. During the upgrade that introduced personal currencies, existing users inherited its former value once; changing or retaining that environment variable afterward has no effect. Currency selection changes formatting and validation, not the numeric value of stored amounts.

Social Login (OAuth/OIDC)

Enable social sign-in providers and generic OIDC SSO.

VariableDescriptionDefault
OAUTH_AUTO_REGISTERAuto-create users on first social logintrue (self-hosted)
OAUTH_GOOGLE_ENABLEDEnable Google loginfalse
OAUTH_APPLE_ENABLEDEnable Apple loginfalse
OAUTH_MICROSOFT_ENABLEDEnable Microsoft loginfalse
OAUTH_OIDC_ENABLEDEnable generic OIDC loginfalse

Provider-specific credentials and advanced OIDC claim mapping are documented in Social Login (OIDC).

Email Configuration

Required for user invitations, password resets, email verification, and email OTP.

VariableDescriptionDefault
EMAIL_PROVIDEROutbound provider: smtp, resend, or noneAuto-detects Resend/SMTP config
SMTP_HOSTSMTP server hostnameNone
SMTP_PORTSMTP server port587 or 465 when SSL is enabled
SMTP_USERNAMESMTP username, optional for relaysNone
SMTP_PASSWORDSMTP password, optional for relaysNone
SMTP_USE_TLSUse STARTTLStrue unless SSL is enabled
SMTP_USE_SSLUse implicit SSL/TLSfalse
SMTP_TIMEOUTSMTP connection timeout in seconds10
RESEND_API_KEYResend API key for Resend providerNone
FROM_EMAILSender email address[email protected]
APP_URLApplication URL for email linkshttp://localhost:5000
Email Required for Invitations

Without email configured, invitation emails, password reset emails, and email OTP codes cannot be sent. See Email Setup for SMTP and Resend examples.

CORS Configuration

Control which domains can access your BillManager API.

VariableDescriptionDefault
ALLOWED_ORIGINSComma-separated list of allowed originsUses APP_URL or localhost

Priority Order

The application determines allowed CORS origins using this priority:

  1. ALLOWED_ORIGINS - Explicit comma-separated list (recommended for multiple frontends)
  2. APP_URL - Single origin (typical for production)
  3. Localhost defaults - Development only (http://localhost:5173, http://localhost:5001, http://127.0.0.1:5173, http://127.0.0.1:5001)

Examples

Single production domain:

environment:
- APP_URL=https://bills.yourdomain.com

Multiple domains (e.g., mobile app + web):

environment:
- ALLOWED_ORIGINS=https://bills.yourdomain.com,https://app.yourdomain.com,https://mobile.yourdomain.com

Development (automatically uses localhost):

environment:
# No CORS configuration needed - automatically allows localhost
- DATABASE_URL=postgresql://...
- FLASK_SECRET_KEY=dev-key
When to Use ALLOWED_ORIGINS vs APP_URL
  • Use ALLOWED_ORIGINS when you have multiple frontends (web app, mobile app, admin panel, etc.)
  • Use APP_URL for simple single-domain deployments
  • Don't set either for local development (localhost is allowed by default)

Social Login & Two-Factor Authentication

BillManager supports social login (Google, Apple, Microsoft, and generic OIDC providers) and two-factor authentication (email OTP, passkeys, recovery codes). All providers and 2FA are disabled by default.

For full setup instructions, see Social Login Setup.

Quick reference:

VariableDescriptionDefault
OAUTH_GOOGLE_ENABLEDEnable Google loginfalse
OAUTH_APPLE_ENABLEDEnable Apple loginfalse
OAUTH_MICROSOFT_ENABLEDEnable Microsoft loginfalse
OAUTH_OIDC_ENABLEDEnable generic OIDC loginfalse
OAUTH_OIDC_TOKEN_AUTH_METHODGeneric OIDC token endpoint auth methodclient_secret_post
OAUTH_AUTO_REGISTERAuto-create accounts for new social login userstrue (self-hosted)
ENABLE_2FAAllow users to enable two-factor authenticationfalse
ENABLE_PASSKEYSAllow passkey/WebAuthn as a 2FA methodfalse
WEBAUTHN_RP_IDWebAuthn relying-party domainDerived from APP_URL
WEBAUTHN_RP_NAMEName shown by passkey promptsBillManager
WEBAUTHN_ORIGINExact web origin accepted for passkeysAPP_URL
WEBAUTHN_ANDROID_ORIGINSComma-separated android:apk-key-hash: origins for trusted Android signing certificatesUnset

Built-in Security Features

BillManager includes comprehensive security protections enabled by default:

FeatureDescription
JWT AuthenticationSecure token-based authentication with access + refresh tokens
Rate LimitingTiered rate limits: 60/min for reads, 30/min for writes
Content Security PolicyStrict CSP headers prevent XSS and injection attacks
CORS ProtectionConfigurable allowed origins for API security
Input ValidationServer-side validation for all user inputs
Password EnforcementStrong password requirements (8+ chars, mixed case, digit)
Two-Factor AuthenticationOptional email OTP, passkeys, and recovery codes
Social LoginSign in with Google, Apple, Microsoft, or generic OIDC
Row-Level IsolationComplete data separation between user groups
No Configuration Needed

These security features are enabled automatically. No additional configuration is required.

Security Best Practices

1. Generate Strong Secrets

Always use cryptographically secure random values:

openssl rand -hex 32

2. Use Environment Files

Keep secrets out of docker-compose.yml:

services:
billmanager:
image: ghcr.io/brdweb/billmanager:latest
env_file:
- .env

Create a .env file (never commit this to version control):

DATABASE_URL=postgresql://billsuser:securepassword@db:5432/billmanager
FLASK_SECRET_KEY=abc123...
JWT_SECRET_KEY=def456...
EMAIL_PROVIDER=smtp
SMTP_HOST=smtp.example.com
SMTP_USERNAME=billmanager
SMTP_PASSWORD=...

3. Use Docker Secrets (Production)

For production deployments, consider using Docker secrets:

services:
billmanager:
secrets:
- flask_secret
- jwt_secret
environment:
- FLASK_SECRET_KEY_FILE=/run/secrets/flask_secret
- JWT_SECRET_KEY_FILE=/run/secrets/jwt_secret

secrets:
flask_secret:
file: ./secrets/flask_secret.txt
jwt_secret:
file: ./secrets/jwt_secret.txt

Example Configurations

Minimal (Development)

environment:
- DEPLOYMENT_MODE=self-hosted
- DATABASE_URL=postgresql://billsuser:password@db:5432/billmanager
- FLASK_SECRET_KEY=development-only-key

Production with SMTP Email

environment:
- DEPLOYMENT_MODE=self-hosted
- DATABASE_URL=postgresql://billsuser:${DB_PASSWORD}@db:5432/billmanager
- FLASK_SECRET_KEY=${FLASK_SECRET}
- JWT_SECRET_KEY=${JWT_SECRET}
- EMAIL_PROVIDER=smtp
- SMTP_HOST=smtp.example.com
- SMTP_PORT=587
- SMTP_USERNAME=${SMTP_USERNAME}
- SMTP_PASSWORD=${SMTP_PASSWORD}
- SMTP_USE_TLS=true
- SMTP_USE_SSL=false
- [email protected]
- APP_URL=https://bills.yourdomain.com

With Google Login and 2FA

environment:
- DEPLOYMENT_MODE=self-hosted
- DATABASE_URL=postgresql://billsuser:${DB_PASSWORD}@db:5432/billmanager
- FLASK_SECRET_KEY=${FLASK_SECRET}
- JWT_SECRET_KEY=${JWT_SECRET}
- EMAIL_PROVIDER=smtp
- SMTP_HOST=smtp.example.com
- SMTP_PORT=587
- SMTP_USERNAME=${SMTP_USERNAME}
- SMTP_PASSWORD=${SMTP_PASSWORD}
- SMTP_USE_TLS=true
- [email protected]
- APP_URL=https://bills.yourdomain.com
- OAUTH_GOOGLE_ENABLED=true
- OAUTH_GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- OAUTH_GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
- ENABLE_2FA=true

See Social Login Setup for detailed provider configuration and passkey setup.

With Public Registration

environment:
- DEPLOYMENT_MODE=self-hosted
- ENABLE_REGISTRATION=true
- REQUIRE_EMAIL_VERIFICATION=true
- EMAIL_PROVIDER=smtp
- SMTP_HOST=smtp.example.com
- SMTP_PORT=587
- SMTP_USERNAME=${SMTP_USERNAME}
- SMTP_PASSWORD=${SMTP_PASSWORD}
- SMTP_USE_TLS=true
- [email protected]
- APP_URL=https://bills.yourdomain.com