Authentication system supporting multiple methods with configurable user registration for the billing console and billing manager API.
Decabill supports three authentication methods:
- API Key Authentication - Static API key for automation and operator scripts
- Keycloak Authentication - OAuth2/OIDC via Keycloak
- Users Authentication - Built-in user registration with JWT
Each method is configured via environment variables on the billing manager. The billing console runtime config must match the backend method.
Simple authentication using a static API key. Suitable for automation, CI, and single-operator deployments.
Configuration:
AUTHENTICATION_METHOD=api-key
STATIC_API_KEY=your-secure-api-key-hereWhen STATIC_API_KEY is set and AUTHENTICATION_METHOD is unset, the backend may infer api-key mode. See Security - Operational hardening for resolution behavior.
Features:
- All requests require
Authorization: Bearer <key>orAuthorization: ApiKey <key>header - API key authentication grants admin rights on billing admin routes
- No interactive user identity; WebSocket dashboard status is rejected (see Real-time Status)
- Combine with Multi-tenancy and optional
STATIC_API_KEY_TENANT_ID
Enterprise-grade authentication using Keycloak OAuth2/OIDC.
Configuration:
AUTHENTICATION_METHOD=keycloak
KEYCLOAK_AUTH_SERVER_URL=http://localhost:8380
KEYCLOAK_REALM=decabill
KEYCLOAK_CLIENT_ID=billing-manager
KEYCLOAK_CLIENT_SECRET=your-client-secretFeatures:
- OAuth2/OIDC authentication flow in the billing console
- Users are synced to the local
userstable - First synced user gets admin role, subsequent users get user role
- Integration with existing identity providers and MFA via Keycloak
- Per-user
tenant_idenforced by Multi-tenancy
Built-in user registration and authentication with JWT tokens.
Configuration:
AUTHENTICATION_METHOD=users
JWT_SECRET=your-jwt-secret-key
DISABLE_SIGNUP=falseFeatures:
- User registration with email and password
- Email confirmation with 6-character alphanumeric codes
- Password reset functionality
- JWT-based authentication (7-day expiry)
- First registered user gets admin role
- Admin user management (CRUD, lock, unlock)
- Optional signup disable for controlled onboarding
- User registers with email and password
- System checks if signup is enabled (
DISABLE_SIGNUP) - If signup is disabled, registration returns 503 Service Unavailable
- If enabled, user account is created in the current tenant (from
X-Tenant):- First user in the tenant: auto-confirmed and assigned admin role
- Subsequent users: receive confirmation code via email
- User receives confirmation code via email
- User submits email and code on the confirmation page
- System validates code and confirms email
- User can log in
- User enters email and password
- System validates credentials and tenant scope
- System checks email confirmation and account lock state
- JWT token is issued and stored client-side
- Token is included in subsequent HTTP and WebSocket requests
- User requests password reset with email
- System sends 6-character alphanumeric reset code via email
- User submits email, code, and new password
- System validates code and updates password
When DISABLE_SIGNUP=true:
POST /auth/registerreturns 503 with message "Signup is disabled"- Admin user creation via
POST /usersremains available - Billing console hides "Create an account" and redirects
/registerto login
Frontend runtime config should set authentication.disableSignup to match the backend.
- Full access to billing admin routes under
/admin/billing/* - User management (create, read, update, delete, lock, unlock)
- Service type and service plan administration
- Manual invoice and customer profile administration
- Standard customer access: subscriptions, invoices, customer profile
- Cannot access admin routes
- Can change own password and update own profile
- Passwords hashed with bcrypt
- Minimum password length enforced
- Password confirmation required on registration
- JWT tokens expire after 7 days
- Each request verifies the user still exists and is not locked
- Keycloak mode applies the same lock check against the synced local user row
- SPA HTTP interceptor dispatches logout on 401 with session-ending messages
- Authentication endpoints are rate-limited
- Prevents brute force attacks
POST /auth/login- Login with email and passwordPOST /auth/register- Register new user (503 when signup disabled)POST /auth/confirm-email- Confirm email with codePOST /auth/request-password-reset- Request password resetPOST /auth/reset-password- Reset password with codePOST /auth/change-password- Change password (authenticated)
GET /users- List usersPOST /users- Create userGET /users/{id}- Get userPOST /users/{id}- Update userDELETE /users/{id}- Delete userPOST /users/{id}/lock- Lock user accountPOST /users/{id}/unlock- Unlock user account
See Billing Manager OpenAPI for request and response schemas.
flowchart TB
subgraph AUTH["Authentication Methods"]
direction TB
AUTH_METHOD["AUTHENTICATION_METHOD env"]
AUTH_METHOD --> API_KEY["api-key"]
AUTH_METHOD --> KEYCLOAK["keycloak"]
AUTH_METHOD --> USERS["users"]
end
subgraph API_KEY_FLOW["API Key Flow"]
API_KEY --> AK1["STATIC_API_KEY required"]
AK1 --> AK2["Authorization: Bearer or ApiKey header"]
AK2 --> AK3["Admin rights on billing admin routes"]
AK2 --> AK4["No WebSocket dashboard user stream"]
end
subgraph KEYCLOAK_FLOW["Keycloak Flow"]
KEYCLOAK --> KC1["Keycloak OAuth2 / OIDC"]
KC1 --> KC2["User synced to users table"]
KC2 --> KC3["First user = admin, rest = user"]
KC2 --> KC4["tenant_id enforced per request"]
end
subgraph USERS_FLOW["Users Flow"]
USERS --> UF1["JWT-based auth"]
UF1 --> UF2["Register / Login / Confirm Email"]
UF2 --> UF3["DISABLE_SIGNUP: register returns 503"]
UF2 --> UF4["First user in tenant = admin"]
UF4 --> UF5["Admin CRUD and lock/unlock"]
end
- Multi-tenancy - Tenant header and API key scope
- Environment Configuration - Environment variable reference
- Security - Accepted risks - Authentication and tenant scope entries
- Backend Billing Manager - Backend authentication implementation
- Frontend Billing Console - Frontend authentication UI
For detailed API specifications, see Billing Manager OpenAPI.