Free & Open Source Two-Factor Authentication for Dolibarr
Add enterprise-grade Two-Factor Authentication (2FA) to your Dolibarr installation - completely free and open source.
- TOTP Standard - RFC 6238 compliant Time-based One-Time Passwords
- Universal Compatibility - Works with Google Authenticator, Apple Passwords, Authy, Microsoft Authenticator, etc.
- QR Code Setup - Scan and configure in seconds
- User Self-Service - Each user manages their own 2FA settings
- Backup Codes - Emergency access codes for recovery
- Trusted Devices - Skip 2FA on trusted devices for configurable days (1-90)
- IP Blocking - Block suspicious IPs manually, view login attempts and statistics
- Login Logging - Track all login attempts (success, failed 2FA, blocked)
- Optional Enforcement - Admin can make 2FA mandatory for specific users or groups
- Multi-Company Support - Works with Dolibarr Multi-Company module
- Secure - Industry-standard TOTP with 30-second rotating codes
- User enables 2FA in their profile settings
- Scan QR code with authenticator app (Google Auth, Apple Passwords, etc.)
- Enter 6-digit code after normal login
- Done! Account is now protected with 2FA
# 1. Clone into custom modules directory
cd /var/www/dolibarr/htdocs/custom
git clone https://github.com/Gerrett84/dolibarr-totp-2fa.git totp2fa
# 2. Set permissions
chown -R www-data:www-data totp2fa
chmod -R 755 totp2fa
# 3. Activate in Dolibarr
# Setup β Modules β TOTP 2FA β ActivateRequirements: Dolibarr 21.0+, PHP 7.4+, MySQL/MariaDB
- Go to User Profile β 2FA
- Click Enable 2FA
- Scan QR code with your authenticator app
- Enter verification code
- Save backup codes in a safe place
- Activate the module in Setup β Modules
- Configure settings in Setup β TOTP 2FA
- Optionally enforce 2FA for specific users/groups
- β Google Authenticator (iOS, Android)
- β Apple Passwords (iOS 15+, macOS Monterey+)
- β Microsoft Authenticator (iOS, Android)
- β Authy (iOS, Android, Desktop)
- β 1Password (iOS, Android, Desktop)
- β Bitwarden (iOS, Android, Desktop)
- β Any RFC 6238 compliant TOTP app
- Fix: 2FA field misaligned on the login form β The input sat shifted to the left and rendered narrower than the username and password fields above it, on both mobile and desktop. Dolibarr's theme styles the login inputs by id (
.login_table input#username, input#password, input#securitycode) rather than by class, so padding, margins and font-size were never inherited by a field with a different id. The theme's declarations are now mirrored onto#totp_code, and the 2FA row is cloned from the username row so it picks up every class and attribute the theme relies on. - Fix: shield icon clipped β
fa-shield-altis a wider glyph thanfa-user/fa-key; it is now centred inside the theme's 14px icon box and allowed to render past it instead of being cut off on the right.
Note: The mirrored CSS in
login_extension.phpreproduces values fromtheme/eldy/global.inc.php. If a future Dolibarr release changes the login field spacing, that block needs to be updated to match.
- Fix: 2FA-Feld erscheint nicht auf HTTPS-Installationen β Login-Injektion von jQuery
.clone()auf Vanilla-JScreateElementumgeschrieben. Der Clone kopierte stillschweigend den eingebetteten<script nonce="...">des Passwort-Toggle-Handlers mit; auf HTTPS-Seiten schlug die Injektion damit lautlos fehl. Das Feld erscheint nun immer korrekt.
- Security: Remaining XSS fixes β
ip_addressanduser_agentvalues in Stats tab and Login Attempts tab now correctly escaped - Security: Trusted-device fingerprint β Device ID cookie (
totp2fa_did) added as unforgeable component of device hash (HttpOnly, Secure, SameSite=Lax) - Security: Open redirect prevention β
urlfromparameter only accepts relative paths starting with/ - Security: Debug pages access-restricted β
debug_hooks.phpandtest_hook_call.phpnow require admin login (403 for non-admins) - Dolibarr v23 compatibility β
isModEnabled()used instead of deprecated$conf->totp2fa->enabled
- Fix Dolibarr v23 Compatibility - 2FA tab now correctly appears in user profile on Dolibarr v23+
- Fix CSRF Token Error - Disable/Regenerate buttons now work with
MAIN_SECURITY_CSRF_WITH_TOKEN=2(fixes #4)
- IP Blocking - Manually block suspicious IP addresses
- Login Attempt Logging - Track all login attempts with IP, browser, timestamp
- IP Management Admin Page - Three tabs: Login Attempts, IP Blacklist, Statistics
- Top Failing IPs - View and block top failing IPs with one click
- Purge Old Logs - Clean up old login attempt records
- Menu only visible in Setup section (not permanently)
- Dolibarr 21 Support - Lowered minimum version requirement
- Multi-Company Support - Confirmed working with Multi-Company module (thanks @fefed22!)
- Trust Renewal - Enter code on trusted device to renew trust period
- Show remaining trust days on login page
- Skip button for trusted devices (proceed without code)
- Improved UX for trusted device handling
- Trusted Devices - Skip 2FA for trusted devices (configurable 1-90 days)
- Admin-only setting to enable/disable trusted devices
- Detailed trusted devices overview in admin panel
- Automatic device detection (Windows, Mac, Linux, iOS, Android)
- Email notifications (2FA enabled/disabled, 3 failed attempts warning)
- Activity log for all 2FA events
- Admin can disable 2FA for users (emergency)
- Backup codes can be used at login
- Basic TOTP implementation (RFC 6238)
- QR code generation for easy setup
- User profile integration (tab in user settings)
- Login page integration (2FA field on main login)
- Backup codes (10 single-use codes)
- Admin configuration panel with statistics
- German and English translations
- AES-256 encryption for stored secrets
- Rate limiting (5 attempts/minute)
- Standard Compliant - Implements RFC 6238 TOTP
- Secure Secrets - 160-bit secrets, cryptographically random
- Rate Limiting - Protection against brute-force attacks
- Time-based Codes - 30-second validity window
- Database Encryption - Secrets stored encrypted
- No External Dependencies - All TOTP logic is self-contained
Compared to commercial 2FA modules for Dolibarr:
| Feature | This Module | Commercial Modules |
|---|---|---|
| Price | Free (GPL-3.0) | β¬30-50 |
| Open Source | β Yes | β No |
| TOTP/RFC 6238 | β Yes | β Yes |
| QR Code Setup | β Yes | β Yes |
| Backup Codes | β Yes | |
| Self-Service | β Yes | β Yes |
| Community Support | β Yes | β Paid only |
Contributions are welcome! This is a community project.
git checkout -b feature/NewFeature
git commit -m 'Add: Cool Feature'
git push origin feature/NewFeature
# β Create Pull RequestGPL v3 or higher - Same as Dolibarr
Gerrett84 - GitHub
- Dolibarr Community
- RFC 6238 TOTP Standard
- Open Source Security Community
- @fefed22 - Multi-Company & Dolibarr 21 compatibility testing
Questions? β GitHub Issues
Before upgrading, always backup your database:
# Backup 2FA tables
mysqldump -u root -p dolibarr llx_totp2fa_user_settings llx_totp2fa_backup_codes llx_totp2fa_activity_log llx_totp2fa_trusted_devices llx_totp2fa_login_attempts llx_totp2fa_ip_blacklist > totp2fa_backup.sqlCurrent Version: 1.4.5 Status: Stable Compatibility: Dolibarr 21.0+