Overview
Multi-Factor Authentication (MFA) adds an extra layer of security to your Chatwoot installation by requiring users to provide a time-based one-time password (TOTP) in addition to their regular password. This guide will help you enable MFA for your self-hosted Chatwoot instance.Prerequisites
- Chatwoot version 4.6 or higher
- Access to your server’s environment variables
- Ability to restart your Chatwoot application
Configuration Steps
Step 1: Generate Encryption Keys
MFA requires Active Record Encryption keys to securely store user secrets. Use Rails’ built-in encryption initialization command:- Store these keys securely. You’ll need them for the next step and for any future server migrations
- Use different keys for each environment (development, staging, production)
- Never share or commit these keys to version control
Step 2: Configure Environment Variables
Add the following variables to your.env
file using the keys generated in Step 1:
User Setup Guide
Once MFA is configured on your server, users can enable it for their accounts:For Users: Enabling MFA
- Log in to your Chatwoot account
- Navigate to Profile Settings → Security
- Click Enable Two-Factor Authentication
- Scan the QR code with an authenticator app:
- Google Authenticator
- Microsoft Authenticator
- Authy
- 1Password
- Or any TOTP-compatible app
- Enter the 6-digit code from your authenticator app
- Save your backup codes in a secure location (10 alphanumeric 8-character codes)
- Click Verify and Enable
For Users: Logging in with MFA
- Enter your email and password as usual
- When prompted, enter the 6-digit code from your authenticator app
- Alternatively, use a backup code if you don’t have access to your authenticator
For Users: Disabling MFA
- Go to Profile Settings → Security
- Click Disable Two-Factor Authentication
- Enter your current 6-digit code and password
- Confirm the action
Troubleshooting
MFA Not Available
If users don’t see MFA options:- Check encryption keys are set:
- Verify all three keys are configured:
- Ensure application was restarted after configuration
Lost Authenticator Access
If a user loses access to their authenticator:-
Using backup codes:
- Users can log in with one of their saved backup codes (8-character alphanumeric)
- Each code can only be used once
- Example format:
A1B2C3D4
- Admin intervention (if backup codes are also lost):
Security Best Practices
Key Management
- Never commit encryption keys to version control
- Generate separate keys for each environment using
rails db:encryption:init
- Use different keys for development, staging, and production environments
- Rotate keys periodically (requires re-enrollment of all users)
- Backup keys securely - losing them means users can’t authenticate
Server Security
- Use HTTPS only - MFA codes can be intercepted over HTTP
- Enable rate limiting - Chatwoot includes built-in rate limiting for login attempts
- Regular updates - Keep Chatwoot and dependencies updated
- Monitor failed attempts - Review logs for suspicious activity
Migration and Disaster Recovery
Migrating to a New Server
- Export environment variables from old server (including encryption keys)
- Backup database with MFA data
- Set up new server with the same encryption keys (do NOT generate new ones)
- Restore database
- Test MFA login with a test account
rails db:encryption:init
, existing MFA secrets will become unreadable.
Disaster Recovery
If encryption keys are lost:- All users will need to re-enable MFA
- Communicate the issue to users promptly