SAGAR AdaptiveAuth Framework
Advanced Adaptive Authentication Framework with Risk-Based Security
Authentication that adapts to risk in real-time, protecting users while maintaining seamless experience
🚀 Overview
SAGAR AdaptiveAuth is a cutting-edge authentication framework that implements risk-based adaptive authentication. The system dynamically adjusts security requirements based on contextual signals, behavioral biometrics, and real-time risk assessment to protect against modern threats while maintaining optimal user experience.
Key Features:
- Risk-Based Authentication - 5-level security system (0-4) adjusting dynamically
- Multi-Factor Authentication - Support for 2FA, email, and SMS verification
- Behavioral Biometrics - Typing patterns and mouse movement analysis
- Real-Time Session Monitoring - Continuous verification during active sessions
- Framework Usage Tracking - Monitor who integrates your framework
- Anomaly Detection - Automated suspicious activity identification
- Admin Dashboard - Comprehensive monitoring and management tools
- Analytics & Reporting - Charts, PDF, and CSV export capabilities
- Enterprise Ready - Production-optimized with security-first design
🏗️ Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ AdaptiveAuth │ │ Backend │
│ Interface │◄──►│ Framework │◄──►│ Services │
│ (HTML/JS) │ │ │ │ (Your App) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌─────────────────┐
│ Risk Engine │
│ (Real-time) │
└─────────────────┘
│
┌─────────────────┐
│ Analytics & │
│ Monitoring │
└─────────────────┘
📋 Security Levels
| Level | Name | Description | Requirements |
|---|---|---|---|
| 0 | TRUSTED | Known device/IP/browser | Minimal authentication |
| 1 | BASIC | Standard login | Password only |
| 2 | VERIFIED | Unknown IP | Password + Email verification |
| 3 | SECURE | Unknown device | Password + 2FA |
| 4 | BLOCKED | Suspicious activity | Account locked |
🛠️ Tech Stack
- Backend: Python 3.8+, FastAPI
- Database: SQLAlchemy with SQLite/PostgreSQL support
- Authentication: JWT with refresh tokens
- 2FA: TOTP with QR codes
- Frontend: HTML5, JavaScript, Chart.js
- API: RESTful endpoints with OpenAPI documentation
- Security: Rate limiting, input validation, OWASP compliance
🚀 Quick Start
Prerequisites
- Python 3.8 or higher
- pip package manager
Installation
- Clone the repository
git clone https://github.com/yourusername/adaptiveauth.git
cd adaptiveauth
- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
- Configure environment
cp .env.example .env
# Edit .env file with your configuration
- Start the server
python main.py
- Access the application
- API:
http://localhost:8080 - Documentation:
http://localhost:8080/docs - Admin Interface:
http://localhost:8080/static/index.html
🔐 Admin Access
Default admin credentials:
- Email:
admin@adaptiveauth.com - Password:
Admin@123
⚠️ SECURITY NOTICE: Change these credentials immediately after first login!
📊 Admin Dashboard Features
1. User Management
- View all users
- Activate/deactivate accounts
- Manage user roles
2. System Statistics
- User counts and activity
- Session monitoring
- Security metrics
3. Risk Events
- Monitor authentication attempts
- View security alerts
- Track risk patterns
4. Framework Usage Analytics
- Track who uses your framework
- Identify integration patterns
- Monitor usage trends
5. Anomaly Detection
- Identify suspicious activity
- Automatic threat detection
- Pattern recognition
6. Data Export
- Export users to CSV
- Export sessions to CSV
- Export risk events to CSV
- Export framework usage to CSV
7. Analytics & Charts
- User statistics visualization
- Risk distribution charts
- PDF report generation
- CSV report generation
🎯 API Endpoints
Authentication
POST /api/v1/auth/login- User loginPOST /api/v1/auth/register- User registrationPOST /api/v1/auth/adaptive-login- Adaptive login with risk assessmentPOST /api/v1/auth/refresh- Token refreshPOST /api/v1/auth/logout- User logout
2FA Management
POST /api/v1/auth/setup-2fa- Setup two-factor authenticationPOST /api/v1/auth/verify-2fa- Verify TOTP codePOST /api/v1/auth/disable-2fa- Disable 2FA
User Management
GET /api/v1/user/profile- Get user profilePUT /api/v1/user/profile- Update user profilePUT /api/v1/user/change-password- Change passwordGET /api/v1/user/sessions- Get active sessions
Admin Endpoints
GET /api/v1/admin/users- List usersGET /api/v1/admin/statistics- System statisticsGET /api/v1/admin/risk-events- Risk eventsGET /api/v1/admin/anomalies- Anomaly patternsGET /api/v1/admin/framework-statistics- Framework usage statistics
📈 Risk Assessment Factors
The framework evaluates multiple risk factors:
- Device Recognition (30%) - Known devices vs new devices
- Location Analysis (25%) - Geographic location patterns
- Time Patterns (15%) - Login time consistency
- Velocity Checks (15%) - Frequency of attempts
- Behavioral Biometrics (15%) - Typing patterns, mouse movements
🧪 Testing
Run the test suite:
python -m pytest test_framework.py
🚢 Deployment
Docker Deployment
# Build and run with Docker
docker-compose up --build
# Or build standalone image
docker build -t adaptiveauth .
docker run -p 8080:8080 adaptiveauth
Production Deployment
# Use the deployment script
./scripts/deploy.sh # Linux/macOS
# or
scripts\deploy.bat # Windows
🔒 Security Best Practices
- Always use HTTPS in production
- Rotate JWT secrets regularly
- Monitor authentication logs
- Implement rate limiting
- Use strong passwords
- Enable 2FA for admin accounts
- Regular security audits
- Keep dependencies updated
- Validate all inputs
- Sanitize all outputs
🤝 Contributing
We welcome contributions! Please read our CONTRIBUTING.md for guidelines.
Development Setup
# Fork the repository
git clone https://github.com/yourusername/adaptiveauth.git
cd adaptiveauth
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
python -m pytest
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
- Documentation: Built-in at
/docs - Issues: Report bugs on GitHub
- Discussions: Join our community forum
- Contact: [your-email@example.com]
📈 Changelog
v1.0.0 - Initial Release
- Risk-based adaptive authentication (0-4 levels)
- Multi-factor authentication (2FA, email, SMS)
- Behavioral biometrics (typing patterns, mouse tracking)
- Admin dashboard with analytics
- Framework usage tracking
- Anomaly detection
- PDF/CSV reporting capabilities
- Real-time session monitoring
🙏 Acknowledgments
- FastAPI team for the excellent framework
- SQLAlchemy for robust ORM capabilities
- Chart.js for beautiful visualizations
- Open-source community for inspiration
SAGAR AdaptiveAuth Framework - Making authentication smarter and more secure, one adaptive login at a time.
⭐ Star this repository if you found it helpful! 🐛 Report an issue 💡 Request a feature
Metadata
Release files for adaptiveauth 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| adaptiveauth-1.0.0.tar.gz | 61.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adaptiveauth-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 128.8 kB
Release files / adaptiveauth-1.0.0.tar.gz
| Download URL | adaptiveauth-1.0.0.tar.gz |
|---|---|
| Size | 61.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc9f1563406e8c1b3112186dcc105deac9a31b7dd1a2d3cba38555852448bcee
|
|
BLAKE2b-256 checksum How to use checksums |
d4833b30ee3d4c1592f1afe2b87a8c3921538d8e4ee473481632e5bb6e4aaa5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / adaptiveauth-1.0.0-py3-none-any.whl
| Download URL | adaptiveauth-1.0.0-py3-none-any.whl |
|---|---|
| Size | 67.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d1292025287be7c44bba6b0b1dec656ab8dcc08cb83293284500bfb529761e7
|
|
BLAKE2b-256 checksum How to use checksums |
4b929e087d573a46f69e4b9d2c067cd25566d7362154ca64d3f14ae02c5d5abd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|