Security Metrics Repository
Component Detail
Data Layer
medium complexity
backend
0
Dependencies
3
Dependents
0
Entities
0
Integrations
Description
Read-only repository layer that executes optimized SQL queries against audit_logs and sessions tables to retrieve security-relevant aggregates. Does not own or mutate these tables - it projects security-focused views from data owned by the Audit Log and Session Management features.
security-metrics-repository
Responsibilities
- Query audit_logs for security event types (login, logout, failed-auth, role-change) with org-scoped filtering
- Query sessions for active session counts, last-seen timestamps, and IP metadata
- Return aggregated counts and recent event lists within configurable time windows
- Apply tenant isolation via organization_id predicates on every query
Interfaces
getFailedLoginCount(orgId: string, windowMinutes: number): number
getActiveSessions(orgId: string): Session[]
getSecurityAuditEvents(orgId: string, limit: number): AuditLog[]
getLoginAttemptsByUser(userId: string, windowMinutes: number): AuthEvent[]
Relationships
Dependents (3)
Components that depend on this component