A security-focused classroom attendance platform built with Django. It is designed for hotspot/LAN classroom environments and combines authentication, WebAuthn passkeys/device binding, facial verification & liveness evaluation, network presence checks, and tamper-evident audit chains.
- Overview
- Key Capabilities
- Security Modes
- System Architecture
- Technology Stack
- Installation and Setup
- Configuration & Feature Flags
- Automated & Manual Testing
- Threat Model & Residual Risks
- Architecture Document
Traditional attendance systems are vulnerable to proxy attendance, remote relays, and tampering. This project provides multi-proof verification before attendance is accepted:
- Authenticated user account (
student/professor) - Approved classroom hotspot/subnet location
- Active presence heartbeats
- Server-verified biometric match & injectable liveness evaluation
- WebAuthn passkey assertion (hardware/OS-backed)
- Canonical SHA-256 audit hash chain signed by professor key
- Dual Security Modes: Support legacy browser-key sessions while deploying Secure Presence Phase 2 (V2).
- WebAuthn / Passkey Support: Enrol hardware/OS-backed authenticators (
userVerification="required"). - Decoupled Injectable Liveness Interface: Clean
LivenessVerifierprotocol that fails closed if unconfigured. - HTTP Presence Heartbeats: Lightweight polling to maintain active local presence over classroom LAN.
- Strict State Machine:
AttendanceAttemptensures signing challenges are issued only after server-recorded liveness success. - Canonical Hash Chain: Audit log linking each record to a canonical JSON representation signed by the professor's key.
- Concurrency & Replay Controls: Database
UniqueConstrainton(student, session)preventing double-record insertion.
- Default mode for backward compatibility.
- Uses browser-generated ECDSA P-256 keys saved in
localStorage. - Student signs a session-wide network nonce.
- Upgraded protocol providing zero browser-exported private key leakage.
- Multi-step protocol flow:
- Start Attempt: Student initiates attempt on active V2 session over allowed subnet.
- Presence Heartbeat: Server validates active HTTP heartbeat from student IP.
- Server Liveness: Camera image evaluated against enrolled profile via injectable
LivenessVerifier. - Signing Challenge: One-time WebAuthn challenge issued upon liveness success.
- Passkey Assertion: Student completes WebAuthn assertion prompt.
- Atomic Submission: Server verifies assertion, updates passkey counter, and appends signed audit entry.
- Backend: Python 3.10+, Django 5.2, Django REST Framework
- Passkeys / WebAuthn:
webauthn==2.5.0 - Security & Cryptography:
cryptography==46.0.5,pyOpenSSL,cbor2,asn1crypto - Biometrics:
torch,facenet-pytorch,opencv-python,pillow(loaded dynamically) - Database: PostgreSQL (
psycopg2-binary) - Reporting:
openpyxl(XLSX), CSV
-
Activate virtual environment:
..\venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt -
Run database migrations:
python manage.py migrate
-
Run server:
python manage.py runserver_plus 0.0.0.0:8000 --cert-file cert.crt --key-file cert.key
Configured via environment variables or secure_attendance/settings.py:
| Setting | Default | Description |
|---|---|---|
SECURE_PRESENCE_V2_ENABLED |
True |
Global feature flag enabling/disabling Secure V2 mode |
PRESENCE_HEARTBEAT_MAX_AGE_SECONDS |
15 |
Maximum age in seconds for valid HTTP heartbeats |
WEBAUTHN_RP_ID |
"localhost" |
WebAuthn Relying Party ID |
WEBAUTHN_ORIGIN |
"https://localhost:8000" |
WebAuthn allowed origin URL |
LIVENESS_VERIFIER_TYPE |
"unconfigured" |
Liveness adapter ("facenet" or "unconfigured") |
Run full test suite covering legacy regression and V2 protocol tests:
python manage.py test corepython manage.py check --deploy
python manage.py makemigrations --check --dry-run- Legacy Mode: Professor creates legacy session -> student submits using legacy browser key -> check attendance record.
- Passkey Enrolment: Student clicks "Enrol WebAuthn Passkey" -> completes browser OS passkey prompt.
- Secure V2 Mode: Professor starts V2 session -> student starts attempt -> camera liveness frame evaluated -> passkey assertion signed -> attendance marked.
- Replay & Expiry Test: Attempt to resubmit used assertion or expired challenge -> verify server rejection.
- Subnet Disconnect Test: Disconnect from hotspot before final submit -> verify network restriction rejection.
- Audit Tampering Test: Modify canonical report hash in database -> run professor integrity check -> verify failure detected.
Warning
- Residual Real-Time Relay Risk: While network subnet checks and HTTP heartbeats verify that the student's device is connected to the classroom LAN, they do not prove physical distance. A proxy student in the classroom could theoretically relay biometric frames or WebAuthn prompts to an off-site student over a custom tunnel.
- Fail-Closed Policy: In Secure V2 mode, if the liveness verifier is unconfigured or unavailable, the system will fail closed to prevent unauthorized attendance.
For full sequence diagrams, detailed data models, state machines, and rollback procedures, refer to SECURE_PRESENCE_V2.md.