Skip to main content

Advanced Adaptive Authentication Framework with Risk-Based Security

Project description

SAGAR AdaptiveAuth Framework

License: MIT Python FastAPI [Build Status] [Version]

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

  1. Clone the repository
git clone https://github.com/yourusername/adaptiveauth.git
cd adaptiveauth
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
  1. Configure environment
cp .env.example .env
# Edit .env file with your configuration
  1. Start the server
python main.py
  1. 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 login
  • POST /api/v1/auth/register - User registration
  • POST /api/v1/auth/adaptive-login - Adaptive login with risk assessment
  • POST /api/v1/auth/refresh - Token refresh
  • POST /api/v1/auth/logout - User logout

2FA Management

  • POST /api/v1/auth/setup-2fa - Setup two-factor authentication
  • POST /api/v1/auth/verify-2fa - Verify TOTP code
  • POST /api/v1/auth/disable-2fa - Disable 2FA

User Management

  • GET /api/v1/user/profile - Get user profile
  • PUT /api/v1/user/profile - Update user profile
  • PUT /api/v1/user/change-password - Change password
  • GET /api/v1/user/sessions - Get active sessions

Admin Endpoints

  • GET /api/v1/admin/users - List users
  • GET /api/v1/admin/statistics - System statistics
  • GET /api/v1/admin/risk-events - Risk events
  • GET /api/v1/admin/anomalies - Anomaly patterns
  • GET /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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adaptiveauth-1.0.0.tar.gz (61.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adaptiveauth-1.0.0-py3-none-any.whl (67.4 kB view details)

Uploaded Python 3

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

Hashes for adaptiveauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cc9f1563406e8c1b3112186dcc105deac9a31b7dd1a2d3cba38555852448bcee
MD5 fda6aff2f461d8ca5b11cc2f941c23f4
BLAKE2b-256 d4833b30ee3d4c1592f1afe2b87a8c3921538d8e4ee473481632e5bb6e4aaa5f

See more details on using hashes here.

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

Hashes for adaptiveauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d1292025287be7c44bba6b0b1dec656ab8dcc08cb83293284500bfb529761e7
MD5 deda97d367df1e8f3f37783df571b3e4
BLAKE2b-256 4b929e087d573a46f69e4b9d2c067cd25566d7362154ca64d3f14ae02c5d5abd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page