Repository navigation
feat(admin): implement security audit logging and outbound webhooks event system - #28
Merged
Merged
Conversation
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.
Overview
This Pull Request implements the enterprise audit logging and outbound event webhook infrastructure identified in the system roadmap (Tasks 2.23 [FR-2] and 3.1 [FR-3] in
docs/audit/2026-07-20/task.md). It equips AuthKit with immutable security audit logging across all critical authentication/authorization lifecycles and provides an outbound webhook delivery engine with cryptographic signature verification, SSRF protection, automated retries with exponential backoff, and secret rotation grace windows.Key Changes by Feature Area
1. Security Audit Logging System (Task 2.23 / FR-2)
AuditLogPrisma model with comprehensive indexes (userId,action,createdAt,ipAddress) to support high-throughput, structured querying.AuditServicethat captures structured actor data (userId,role,ipAddress,userAgent), event action types, status (SUCCESS,FAILURE), and contextual metadata with automatic sensitive field sanitization.GET /api/v1/admin/audit-logsfeaturing cursor-based pagination and flexible filtering byuserId,action,status, and date ranges (startDate,endDate).2. Webhooks & Outbound Event System (Task 3.1 / FR-3)
WebhookSubscriptionandWebhookDeliverymodels tracking subscription states (ACTIVE,DISABLED), event filters, failure counts, delivery attempts (PENDING,SUCCESS,FAILURE,RETRIES_EXCEEDED), and execution durations.evt_<id>,type,version,timestamp,data) with wildcard*subscription support.X-Webhook-Signatureheaders (t=<timestamp>,v1=<signature>). Secret rotation provides a 24-hour dual-signature grace window emitting bothv1(current secret) andv1_old(previous secret) to eliminate client downtime.Retry-Afterheader adherence, automatic subscription disabling after 10 consecutive failures, and a background queue worker for pending/retry processing.token,password,secret,authorization,jwt) and response body truncation (10 KB max) to protect upstream endpoints and database storage.3. API & Controller Refactoring
/api/v1/admin/webhooks): Implemented complete REST endpoints for subscription creation, cursor-paginated retrieval, ID lookups, updates, deletions, secret rotations, live delivery testing, and delivery attempt inspection.webhook.service.tsto accept strictly typed single-parameter objects, maintaining consistency with core architectural patterns.src/core/common/utils/webhook.util.ts.Documentation & API Specification Updates
README.md: Updated feature capabilities and architecture descriptions to reflect audit logging and outbound webhook integrations.docs/api_endpoints.md: Restructured Section 7 (Admin) into clean subsections:7.1 User Management (/admin/users)7.2 Session Management (/admin/sessions)7.3 OIDC Client Management (/admin/oidc)7.4 Security Audit Logs (/admin/audit-logs)7.5 Webhooks (/admin/webhooks)AuthKit.postman_collection.json): Added a dedicatedWebhooks & Outbound Eventssubfolder inside08. Admin Controls & Role Managementcontaining all 7 parameterized webhook endpoints and automated post-response test assertions.docs/api-specs/openapi.json): Added detailed schemas, request bodies, and responses categorized under theAdmin - Webhookstag.docs/audit/2026-07-20/task.md): Marked Tasks 2.23 and 3.1 as Done.Verification & Test Results
pnpm build,pnpm type-check(tsc --noEmit),pnpm lint(eslint), andpnpm format:check(prettier) with zero errors or warnings.