Skip to content

feat: implement examination identity audit logs for GATEKEEPER#37

Open
Soldier224K wants to merge 1 commit into
mainfrom
issue-22-examination-audit-logs
Open

feat: implement examination identity audit logs for GATEKEEPER#37
Soldier224K wants to merge 1 commit into
mainfrom
issue-22-examination-audit-logs

Conversation

@Soldier224K

@Soldier224K Soldier224K commented May 24, 2026

Copy link
Copy Markdown
Collaborator
  • Add AuditLogService for comprehensive identity event logging
  • Log verification attempts, face matches/mismatches, suspicious events
  • Log admin override actions and examination access decisions
  • Add get_timeline() for roll-number or session filtered audit trails
  • Add search() for querying audit log content
  • Add 15 tests covering all audit logging functionality

closes #22

- Add AuditLogService for comprehensive identity event logging
- Log verification attempts, face matches/mismatches, suspicious events
- Log admin override actions and examination access decisions
- Add get_timeline() for roll-number or session filtered audit trails
- Add search() for querying audit log content
- Add 15 tests covering all audit logging functionality
Copilot AI review requested due to automatic review settings May 24, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new backend audit logging service intended to capture identity/verification-related events for the GATEKEEPER domain, plus accompanying unit tests to validate event creation and querying APIs.

Changes:

  • Added AuditLogService/AuditEvent to record identity events (verification attempts, matches/mismatches, suspicious events, admin overrides, exam access).
  • Added timeline and query helpers (get_timeline, get_session_timeline, get_events_by_type, search, count, clear).
  • Added a new pytest suite (test_audit_log.py) covering the audit log API end-to-end.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.

File Description
backend/src/services/audit_log.py Adds the audit log service + event model and querying helpers.
backend/tests/test_audit_log.py Adds unit tests covering event logging, filtering, searching, and determinism checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,201 @@
from typing import Optional, List, Dict, Any
from dataclasses import dataclass, field
Comment on lines +46 to +49
event = AuditEvent(
event_id=self._generate_event_id(roll_number, "verification_attempt", datetime.now(timezone.utc)),
timestamp=datetime.now(timezone.utc),
event_type="verification_attempt",
Comment on lines +68 to +71
event = AuditEvent(
event_id=self._generate_event_id(roll_number, "face_match", datetime.now(timezone.utc)),
timestamp=datetime.now(timezone.utc),
event_type="face_match",
Comment on lines +90 to +93
event = AuditEvent(
event_id=self._generate_event_id(roll_number, "face_mismatch", datetime.now(timezone.utc)),
timestamp=datetime.now(timezone.utc),
event_type="face_mismatch",
Comment on lines +113 to +116
event = AuditEvent(
event_id=self._generate_event_id(roll_number, "suspicious_identity", datetime.now(timezone.utc)),
timestamp=datetime.now(timezone.utc),
event_type="suspicious_identity",
Comment on lines +160 to +163
event = AuditEvent(
event_id=self._generate_event_id(roll_number, "examination_access", datetime.now(timezone.utc)),
timestamp=datetime.now(timezone.utc),
event_type="examination_access",
query_lower = query.lower()
results = []
for event in self._logs:
payload_str = json.dumps(event.payload).lower()
Comment on lines +31 to +33
def __init__(self):
self._logs: List[AuditEvent] = []

Comment on lines +30 to +33
class AuditLogService:
def __init__(self):
self._logs: List[AuditEvent] = []

Comment on lines +165 to +166
import time
from datetime import datetime, timezone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISSUE 8 — Audit Logging & Identity Timeline

2 participants