🎯 CB2FA is now a PLATFORM, not just Matrix implementation! 📦 New Structure: • /matrix/ - Matrix implementation (moved from root) • /core/ - Shared components (i18n, queue, types) • /docs/ - Architecture documentation • Root README - CB2FA platform overview 🌍 Platform Vision: • Matrix ✅ (first implementation) • Telegram ⏳ (planned) • Discord ⏳ (planned) • Webhooks ⏳ (planned) • Slack ⏳ (planned) 📚 Documentation: • Architecture overview in /docs/ • Platform-specific guides in each implementation • Shared components documented in /core/ 🚀 Ready for multi-platform expansion! Trust people, not devices. - CB2FA Platform
4.4 KiB
CB2FA - Community-Based Two-Factor Authentication
Made for Matrix with love by EasyProTech LLC (www.easypro.tech)
Developer: Brabus
Overview
CB2FA is a lightweight, community-based two-factor authentication system for Matrix homeservers. It intercepts login requests and requires approval from trusted community members via simple y/n commands in a Matrix room.
Features
- 🔐 Community-based approval - Trust your community members to approve logins
- ✅ Simple y/n commands - No complex UI, just reply 'y' or 'n' in Matrix
- 📊 Clean tables - Clear display of login details
- 🌍 Internationalization - English and Russian language support
- ⚡ Lightweight - Built with Deno and TypeScript, minimal dependencies
- 🛡️ Secure - Validates credentials with Synapse before requesting approval
- 🔄 Smart Queue - Handles multiple simultaneous login attempts elegantly
- 📦 Fully Portable - No hardcoded domains or paths, works anywhere
Quick Start
-
Clone and Configure:
git clone <repo> cd cb2fa cp .env.example .env # Edit .env with your Matrix settings -
Install Deno:
curl -fsSL https://deno.land/install.sh | sh -
Start Services:
# Start the bot deno run --allow-net --allow-env --allow-read src/main.ts # Start the middleware (in another terminal) deno run --allow-net --allow-env --allow-read middleware/middleware.ts -
Configure nginx to proxy login requests:
location ~ ^/_matrix/client/(r0|v3)/login$ { proxy_pass http://127.0.0.1:9999; # or your CB2FA_MIDDLEWARE_PORT proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; }
Configuration (.env)
# Matrix Configuration
MATRIX_HOMESERVER_URL=http://localhost:8008
MATRIX_BOT_USERNAME=cb2fa_bot
MATRIX_BOT_PASSWORD=your_bot_password
MATRIX_DOMAIN=your-matrix-domain.com
# CB2FA Settings
MATRIX_ADMIN_FOR_AUTH=admin
CB2FA_INVITED_USERS=admin,alice,bob
CB2FA_ROOM_NAME=CB2FA Authorization
CB2FA_TIMEOUT_MINUTES=15
# Ports (customize as needed)
CB2FA_BOT_PORT=10000
CB2FA_MIDDLEWARE_PORT=9999
# Language
LANGUAGE=en
How It Works
- User attempts Matrix login via any client (Element, etc.)
- nginx routes login to CB2FA middleware
- Middleware validates credentials with Synapse
- If valid, creates approval request via bot
- Bot sends clean table to Matrix room
- Community members respond with simple 'y' or 'n'
- Login succeeds or fails based on community decision
Queue System
- ✅ One active request at a time - Clear focus for trusted users
- ✅ Automatic queue management - Others wait in line
- ✅ No user confusion - Standard Matrix "connecting..." experience
- ✅ Anti-DDoS protection - Natural rate limiting
Architecture
User Login → nginx → CB2FA Middleware → Queue → Bot → Matrix Room → Trusted User Decision
Production Deployment
- Create Matrix bot account
- Configure environment variables
- Set up nginx proxy
- Run as systemd services
- Invite trusted users to CB2FA room
License
MIT License - Made with ❤️ for the Matrix community
Deploy anywhere, configure everything, hardcode nothing! 🚀
🌍 Supported Languages
CB2FA supports multiple languages for the interface:
- 🇬🇧 English (
LANGUAGE=en) - Default - 🇷🇺 Russian (
LANGUAGE=ru) - Русский - 🇩🇪 German (
LANGUAGE=de) - Deutsch - 🇨🇳 Chinese (Simplified) (
LANGUAGE=zh-cn) - 中文 (简体) - 🇫🇷 French (
LANGUAGE=fr) - Français - 🇪🇸 Spanish (
LANGUAGE=es) - Español - 🇹🇷 Turkish (
LANGUAGE=tr) - Türkçe
Simply set the LANGUAGE variable in your .env file to switch languages.
📸 Screenshots
CB2FA showing clean login approval tables in Matrix chat with trusted users bob, maya, and alice
📞 Support
I do not provide support. I do not consult — not for free, not for money, not in any form.
Please don't ask for help, fixes, or explanations — this project is released as-is.
If someone wants to help with development — contributions are welcome. But there are no obligations from my side whatsoever.