Feature/admin audit log UI - #443
Open
uche102 wants to merge 2 commits into
Open
Conversation
…d retention purge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes the platform audit logging system (#135) through a dedicated Admin UI and RBAC-restricted API endpoints. Authorized administrators can search, filter, inspect event details (including before/after state changes), export filtered results in CSV or JSON format, and trigger log retention purging.
Acceptance Criteria Covered
authenticateandrequireAdminmiddleware.Key Implementation Details
1. Backend Service (
backend/src/services/auditService.ts)$regextext matching acrossactor,action,resource,resourceId, and error messages.exportLogs(options, format)producing formatted CSV or pretty-printed JSON output.purgeOldLogs(retentionDays)to delete audit entries older than the retention threshold.2. Admin Query Routes (
backend/src/routes/admin/audit.ts)GET /api/admin/audit: Paginated, multi-field search and filter endpoints.GET /api/admin/audit/stats: Aggregated metrics for success/failure rates and top actors.GET /api/admin/audit/export: Triggers CSV or JSON download withContent-Dispositionheaders.POST /api/admin/audit/purge: Retention purging action ({ retentionDays: number }).GET /api/admin/audit/:id: Retrieves full details for a single audit event./api/admin/auditand/api/v1/admin/auditinbackend/src/index.ts.3. Frontend Admin UI (
frontend/src/app/admin/audit/page.tsx)AdminSidebar.tsx.Files Changed
backend/src/services/auditService.ts(Modified)backend/src/routes/admin/audit.ts(New)backend/src/index.ts(Modified)frontend/src/app/admin/audit/page.tsx(New)frontend/src/components/Admin/AdminSidebar.tsx(Modified)How to Test
-Closes #400