feat(auth): Program.cs integration for Audit Logging (AEG-AUTH-001 Part 2)
- Register IAuthAuditSql (AuthAuditSql) in DI - Add AuthAuditMiddleware to pipeline after authentication - Fix AuthAuditSql using statement + NpgsqlInet construction - Fix GetAuditLogsEndpoint response mapping (AuthAuditLogEntry → AuditLogItem) - Build verified (Release mode, 0 errors) Implements audit trail for all /api/auth/* endpoints: - Captures event type, status, IP, user agent, endpoint, error details - Immutable append-only storage with compliance views - Async non-blocking logging with graceful failure handling - Ready for 0047 migration application and testing WBS: AEG-X-005 (JWT/OIDC/fail-closed) + AEG-AUTH-001 (Audit) Gate: G3 (Shadow Run API) Status: CODE_COMPLETE → MIGRATION_READY Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,13 +47,29 @@ public sealed class GetAuditLogsEndpoint : Endpoint<GetAuditLogsRequest, GetAudi
|
||||
ct: ct
|
||||
);
|
||||
|
||||
var items = logs.Select(entry => new AuditLogItem
|
||||
{
|
||||
AuditId = entry.AuditId,
|
||||
EventType = entry.EventType,
|
||||
IdentityId = entry.IdentityId,
|
||||
Username = entry.Username,
|
||||
Role = entry.Role,
|
||||
IpAddress = entry.IpAddress,
|
||||
Endpoint = entry.Endpoint,
|
||||
HttpMethod = entry.HttpMethod,
|
||||
Status = entry.Status,
|
||||
ErrorCode = entry.ErrorCode,
|
||||
ErrorMessage = entry.ErrorMessage,
|
||||
OccurredAt = entry.OccurredAt
|
||||
}).ToList();
|
||||
|
||||
await Send.OkAsync(new GetAuditLogsResponse
|
||||
{
|
||||
Items = logs.ToList(),
|
||||
Items = items,
|
||||
Total = total,
|
||||
Page = req.Page,
|
||||
PageSize = req.PageSize
|
||||
}, 200, ct);
|
||||
}, ct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user