Spaces:
Running
Running
metadata
title: AdaptiveAuth
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
SAGAR AdaptiveAuth Framework
SAGAR AdaptiveAuth is a FREE, open-source authentication framework with JWT, 2FA, and adaptive risk-based authentication.
Key Features
- π JWT Authentication with token management
- π Two-Factor Authentication (TOTP with QR codes)
- π Risk-Based Adaptive Authentication (Security levels 0-4)
- π Behavioral Analysis (device, IP, location tracking)
- π Step-up Authentication for high-risk scenarios
- π Continuous Session Monitoring
- π Anomaly Detection (brute force, credential stuffing)
- π Admin Dashboard with real-time risk monitoring
- π Password Reset with email verification
Installation & Quick Start
1. Clone the repository
git clone https://github.com/Sagar1566/HackWack.git
cd HackWack/AdaptiveAuth
2. Install dependencies
pip install -r requirements.txt
3. Run the application
python main.py
The server will start at http://localhost:8000
Alternative: Use the start script:
- On Windows: Double-click
start_server.bat - On Linux/Mac: Run
./start_server.sh
How to Use the Framework
Option 1: Integrate with Your Existing FastAPI App
from fastapi import FastAPI
from adaptiveauth import AdaptiveAuth
app = FastAPI()
# Initialize AdaptiveAuth
auth = AdaptiveAuth(
database_url="sqlite:///./app.db",
secret_key="your-super-secret-key"
)
# Mount all authentication routes
app.include_router(auth.router, prefix="/api/v1/auth")
Option 2: Run Standalone Server
Use the main application file to run as a standalone authentication service.
Available API Endpoints
After starting the server, visit http://localhost:8000/docs for interactive API documentation.
Authentication
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- Standard loginPOST /api/v1/auth/adaptive-login- Risk-based adaptive loginPOST /api/v1/auth/step-up- Step-up verificationPOST /api/v1/auth/logout- Logout user
User Management
GET /api/v1/user/profile- Get user profilePUT /api/v1/user/profile- Update profileGET /api/v1/user/security- Security settingsGET /api/v1/user/sessions- Active sessionsPOST /api/v1/user/change-password- Change password
2FA
POST /api/v1/auth/enable-2fa- Enable 2FAPOST /api/v1/auth/verify-2fa- Verify 2FAPOST /api/v1/auth/disable-2fa- Disable 2FA
Risk Assessment
POST /api/v1/adaptive/assess- Assess current riskGET /api/v1/adaptive/security-status- Get security statusPOST /api/v1/adaptive/verify-session- Verify sessionPOST /api/v1/adaptive/challenge- Request challengePOST /api/v1/adaptive/verify- Verify challenge
Admin Dashboard
GET /api/v1/admin/users- List usersGET /api/v1/admin/statistics- Dashboard statisticsGET /api/v1/admin/risk-events- Risk eventsGET /api/v1/risk/overview- Risk dashboard
Security Levels
| Level | Risk | Authentication Required | Description |
|---|---|---|---|
| 0 | Low | Password | Known device + IP + browser |
| 1 | Medium | Password | Unknown browser |
| 2 | High | Password + Email | Unknown IP address |
| 3 | High | Password + 2FA | Unknown device |
| 4 | Critical | Blocked | Suspicious activity |
Examples
Check out run_example.py for a complete integration example.
Testing the Framework
To verify the framework works correctly, run:
python test_framework.py
For detailed testing instructions, see HOW_TO_TEST.md.
License
MIT License - Completely FREE and OPEN SOURCE
- β Use in personal projects
- β Use in commercial projects
- β Modify and distribute
- β No attribution required
- β No licensing fees