feat: Implement centralized audit logging admin interface (refs #10)
Deploy to Staging / Build Images (pull_request) Successful in 4m42s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
Deploy to Staging / Verify Staging (pull_request) Failing after 6s
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 6s
Deploy to Staging / Build Images (pull_request) Successful in 4m42s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
Deploy to Staging / Verify Staging (pull_request) Failing after 6s
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 6s
- Add audit_logs table with categories, severities, and indexes - Create AuditLogService and AuditLogRepository - Add REST API endpoints for viewing and exporting logs - Wire audit logging into auth, vehicles, admin, and backup features - Add desktop AdminLogsPage with filters and CSV export - Add mobile AdminLogsMobileScreen with card layout - Implement 90-day retention cleanup job - Remove old AuditLogPanel from AdminCatalogPage Security fixes: - Escape LIKE special characters to prevent pattern injection - Limit CSV export to 5000 records to prevent memory exhaustion - Add truncation warning headers for large exports 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
8c7de98a9a
commit
c98211f4a2
@@ -0,0 +1,55 @@
|
||||
# audit-log/
|
||||
|
||||
Centralized audit logging system for tracking all user and system actions.
|
||||
|
||||
## Files
|
||||
|
||||
| File | What | When to read |
|
||||
| ---- | ---- | ------------ |
|
||||
| `README.md` | Architecture and API documentation | Understanding audit log system |
|
||||
|
||||
## Subdirectories
|
||||
|
||||
| Directory | What | When to read |
|
||||
| --------- | ---- | ------------ |
|
||||
| `api/` | HTTP endpoints for log viewing/export | API route changes |
|
||||
| `domain/` | Business logic, types, service | Core audit logging logic |
|
||||
| `data/` | Repository, database queries | Database operations |
|
||||
| `jobs/` | Scheduled cleanup job | Retention policy |
|
||||
| `migrations/` | Database schema | Schema changes |
|
||||
| `__tests__/` | Integration tests | Adding or modifying tests |
|
||||
|
||||
## Key Files
|
||||
|
||||
| File | What | When to read |
|
||||
| ---- | ---- | ------------ |
|
||||
| `audit-log.instance.ts` | Singleton service instance | Cross-feature logging |
|
||||
| `domain/audit-log.types.ts` | Types, categories, severities | Type definitions |
|
||||
| `domain/audit-log.service.ts` | Core logging operations | Creating/searching logs |
|
||||
| `data/audit-log.repository.ts` | Database queries | Data access patterns |
|
||||
| `jobs/cleanup.job.ts` | 90-day retention cleanup | Retention enforcement |
|
||||
|
||||
## Usage
|
||||
|
||||
Import the singleton for cross-feature logging:
|
||||
|
||||
```typescript
|
||||
import { auditLogService } from '../../audit-log';
|
||||
|
||||
// Log with convenience methods
|
||||
await auditLogService.info('vehicle', userId, 'Vehicle created', 'vehicle', vehicleId);
|
||||
await auditLogService.warning('auth', userId, 'Password reset requested');
|
||||
await auditLogService.error('system', null, 'Backup failed', 'backup', backupId);
|
||||
```
|
||||
|
||||
## Categories
|
||||
|
||||
- `auth`: Login, logout, password changes
|
||||
- `vehicle`: Vehicle CRUD operations
|
||||
- `user`: User management actions
|
||||
- `system`: Backups, imports/exports
|
||||
- `admin`: Admin-specific actions
|
||||
|
||||
## Retention
|
||||
|
||||
Logs older than 90 days are automatically deleted by a daily cleanup job (3 AM).
|
||||
Reference in New Issue
Block a user