Skip to content

Divya1473/continuous-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Continuous Authentication Using Behavioral Patterns

A final year engineering project that continuously verifies user identity every second using three behavioral biometric signals — silently, in the background, without interrupting normal workflow.

Built by **Divya Powar


🎯 Problem It Solves

Traditional authentication (passwords, fingerprint) verifies identity only once at login. After that, anyone can use the active session undetected. This system re-verifies the user every second throughout the entire session.


🧠 How It Works

Three ML models run simultaneously in the background:

Modality Model Features Weight
👤 Face Recognition FaceNet (InceptionResnetV1) 512-d cosine similarity 50%
⌨️ Keystroke Dynamics LSTM Autoencoder Dwell, flight, digraph time 30%
🖱️ Mouse Dynamics GRU Autoencoder Speed, angle, curvature, acceleration 20%

All three scores are fused into one confidence score: fusion = 0.5 × face + 0.3 × keystroke + 0.2 × mouse

  • Score ≥ 0.55 → ✅ Authenticated
  • Score 0.40–0.55 → ⚠️ Warning
  • Score < 0.40 → 🚨 Alert triggered

🏗️ System Architecture

Chrome Extension (content.js) Desktop Agent (agent.py) User Portal keystrokes + mouse capture webcam @ 1fps registration wizard ↓ ↓ ↓ background.js (WebSocket) JPEG base64 POST REST API calls ↓ ↓ ↓ ╔══════════════════════════════════════════════════════════════╗ ║ FastAPI Backend (localhost:8000) ║ ║ Auth Router │ Register Router │ Admin Router │ WebSocket Hub ║ ║ SessionService │ AlertService │ DataStore │ FusionEngine ║ ╚══════════════════════════════════════════════════════════════╝ ↓ ↓ ↓ FaceNet LSTM model GRU model (face_model.py) (keystroke_model.py) (mouse_model.py) ↓ ↓ ↓ SQLite DB Per-user model files Admin Portal (auth.db) (.h5, .npy, .pkl) (React, port 5173)

📦 Tech Stack

Backend

  • Python 3.10.11
  • FastAPI + Uvicorn (REST + WebSocket)
  • SQLAlchemy + SQLite

Machine Learning

  • facenet-pytorch (FaceNet + MTCNN)
  • TensorFlow / Keras (LSTM + GRU Autoencoders)
  • PyTorch, OpenCV, scikit-learn, NumPy

Frontend

  • React 18 + Vite
  • React Router DOM v6
  • Axios, Lucide React

Browser Extension

  • Chrome Manifest V3
  • Service Worker + Content Script

📁 Project Structure

continuous-auth/ ├── backend/ │ ├── app/ │ │ ├── main.py ← FastAPI app entry │ │ ├── models.py ← DB table definitions │ │ ├── schemas.py ← Pydantic validators │ │ ├── websocket.py ← WebSocket hub │ │ ├── routers/ │ │ │ ├── auth.py ← Live auth endpoints │ │ │ ├── register.py ← Registration endpoints │ │ │ └── admin.py ← Admin endpoints │ │ ├── ml/ │ │ │ ├── face_model.py ← FaceNet pipeline │ │ │ ├── keystroke_model.py ← LSTM autoencoder │ │ │ ├── mouse_model.py ← GRU autoencoder │ │ │ └── fusion.py ← Score fusion engine │ │ └── services/ │ │ ├── data_store.py ← File I/O │ │ ├── session.py ← Session management │ │ └── alerts.py ← Alert management │ ├── data/users/{username}/ ← Per-user models + data │ ├── db/auth.db ← SQLite database │ ├── register_face.py ← Face capture script │ ├── collect_keystrokes.py ← Keystroke capture script │ ├── collect_mouse.py ← Mouse capture script │ └── run.py ← Start backend server ├── desktop-agent/ │ └── agent.py ← Webcam monitoring agent ├── extension/ │ ├── manifest.json ← Chrome MV3 config │ ├── popup/ ← Extension UI │ ├── content/content.js ← Behavioral capture │ └── background/background.js ← Service worker ├── admin-portal/ │ └── src/ │ ├── user/ ← Registration + guide │ └── admin/ ← Dashboard + management └── START_ALL.bat ← One-click startup

🚀 Getting Started

Prerequisites

  • Python 3.10.11
  • Node.js 20.x
  • Google Chrome browser

1. Clone the repository

git clone https://github.com/yourusername/continuous-auth.git
cd continuous-auth

2. Start the backend

cd backend
python -m venv venv
venv\Scripts\activate        # Windows
pip install -r requirements.txt
python run.py

Visit http://localhost:8000/docs to verify ✅

3. Start the admin + user portal

cd admin-portal
npm install
npm run dev

Visit http://localhost:5173

4. Load the Chrome extension

  1. Open Chrome → chrome://extensions/
  2. Enable Developer mode
  3. Click Load unpacked
  4. Select the extension/ folder

5. Register a new user

http://localhost:5173/register → Step 1: Create username → Step 2: Capture 30 face images → Step 3: Type for 5-10 minutes (200+ sequences) → Step 4: Use mouse for 3-5 minutes (200+ sequences) → Step 5: Train all 3 models (2-3 minutes)

6. Start authentication session

# Terminal 1 — Backend (already running)

# Terminal 2 — Start webcam agent
cd desktop-agent
..\backend\venv\Scripts\activate
python agent.py --username your_username

# Browser — Click CA extension icon → Start Session

📊 Results (testuser)

Metric Value
Face images collected 30
FaceNet embeddings 30 × 512-d
Keystroke sequences 590
Mouse sequences 1590
Live face score 0.82 – 0.87
Live fusion score 0.66 – 0.76
Alert response time ~1 second
System latency < 300ms per cycle

⚠️ Alert Scenarios

Scenario Detection Alert Type
User covers webcam ✅ Yes NO_FACE
Unknown person only ✅ Yes UNKNOWN_FACE
User + stranger together ✅ No alert
Impostor typing ✅ Yes LOW_FUSION_SCORE

🔭 Future Scope

  • Liveness detection (blink, depth analysis)
  • System-wide capture (not just browser)
  • Cloud deployment with HTTPS + PostgreSQL
  • Adaptive fusion weights
  • Mobile behavioral authentication

📄 License

This project is built for academic purposes. PES Modern College of Engineering, Pune — 2024–25


🙏 Acknowledgements

About

A real-time continuous authentication system using face recognition (FaceNet), keystroke dynamics (LSTM Autoencoder), and mouse dynamics (GRU Autoencoder) with a Chrome extension, FastAPI backend, and React admin portal.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages