Advanced Adaptive Authentication Framework with Risk-Based Security
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adaptiveauth-1.0.0.tar.gz.
File metadata
- Download URL: adaptiveauth-1.0.0.tar.gz
- Upload date:
- Size: 61.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc9f1563406e8c1b3112186dcc105deac9a31b7dd1a2d3cba38555852448bcee
|
|
| MD5 |
fda6aff2f461d8ca5b11cc2f941c23f4
|
|
| BLAKE2b-256 |
d4833b30ee3d4c1592f1afe2b87a8c3921538d8e4ee473481632e5bb6e4aaa5f
|
File details
Details for the file adaptiveauth-1.0.0-py3-none-any.whl.
File metadata
- Download URL: adaptiveauth-1.0.0-py3-none-any.whl
- Upload date:
- Size: 67.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d1292025287be7c44bba6b0b1dec656ab8dcc08cb83293284500bfb529761e7
|
|
| MD5 |
deda97d367df1e8f3f37783df571b3e4
|
|
| BLAKE2b-256 |
4b929e087d573a46f69e4b9d2c067cd25566d7362154ca64d3f14ae02c5d5abd
|