feat: add userName tracking to audit events
- Add userName column to AuditEvent schema with index and migration - Add GET /api/v1/auth/me endpoint returning current user identity - AuditCollector auto-fills userName from session→user map, resolved lazily via /auth/me on first session creation - Support userName and date range (from/to) filtering on audit events and sessions endpoints - Audit console sidebar groups sessions by project → user - Add date filter presets (d key: all/today/1h/24h/7d) to console - Add scrolling and page up/down to sidebar navigation - Tests: auth-me (4), audit-username collector (4), route filters (2), smoke tests (2) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "AuditEvent" ADD COLUMN "userName" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AuditEvent_userName_idx" ON "AuditEvent"("userName");
|
||||
@@ -288,6 +288,7 @@ model AuditEvent {
|
||||
serverName String?
|
||||
correlationId String?
|
||||
parentEventId String?
|
||||
userName String?
|
||||
payload Json
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@ -296,6 +297,7 @@ model AuditEvent {
|
||||
@@index([correlationId])
|
||||
@@index([timestamp])
|
||||
@@index([eventKind])
|
||||
@@index([userName])
|
||||
}
|
||||
|
||||
// ── Audit Logs ──
|
||||
|
||||
Reference in New Issue
Block a user