Repository navigation
feat(admin): audit log page in the admin panel - #20
Merged
Merged
Conversation
Successful audit events are now stored in a new AuditEvents table (with a migration for every provider) and listed on Admin > Audit log: paged, newest first, filterable by event, actor, feed, target or package id and a range of UTC days. Only admins can open it. WebAuditLog is the one path for every AUDIT line: the NuGet API lines of PackagePublishController and SymbolController moved onto it. The line format and placeholders are unchanged, but all lines now use the PaGetto.Web.Audit.WebAuditLog log category. Only Information events are stored; denied and failed attempts are still only logged, so a noisy client can't fill the table. Events are stored in a scope of their own, so recording one never saves changes the caller hasn't saved yet, and a failure to store one is logged without failing the request. Audit:RetentionDays (default 30, 0 keeps events forever, validated at startup) is applied by AuditRetentionService at startup and then daily. Closes #13
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.
Store successful audit events and list them on Admin > Audit log
AuditEvententity (time, event, actor, IP, feed, target, detail, package id/version) with anAddAuditEventsmigration for Sqlite, SqlServer, PostgreSql and MySql, and an index onTimestampUtc.WebAuditLogis the one path for everyAUDITline: the NuGet API lines ofPackagePublishControllerandSymbolControllermoved onto it. Message format and placeholders are unchanged; all lines now use thePaGetto.Web.Audit.WebAuditLoglog category (docs andappsettings.jsonupdated).Information(successful) events are stored; denied and failed attempts stay log-only, so a noisy client can't flood the table. Each event is stored in its own DI scope, so recording one never saves changes the caller hasn't saved yet (e.g. mirror edits on Feed settings), and a storage failure is logged without failing the request.Pages/Admin/Audit(admins only, new tab): paged (50 per page), newest first, filters for event, actor, feed, target or package id and a UTC date range. Dates are culture-independent (Html.DisplayDate).Audit:RetentionDays(default 30,0keeps events forever, negative values fail validation) applied byAuditRetentionServiceat startup and then daily.WebAuditLogmethods are now async (AdminAsync,PackageAsync,SymbolAsync); call sites updated, includinggroup_updatedfrom feat(admin): edit the name and description of a group #15, which is also added to the documented event table.AuditEventServiceTests,AuditRetentionServiceTests,AuditModelFacts(filters, paging, non-admin redirect),WebAuditLogFacts,PackagePublishControllerFacts(stored only on success),ValidatePaGettoOptionsTests, and anAuditLogIntegrationTestspush through the API. Docs for the page and the config key, and rows U1 to U4 intestenv/UI-TESTS.md.Verified U1 to U4 against the testenv snapshot with a locally built image: the migration applies to the snapshot, group create/delete and an API push by
aliceshow up, the rejected duplicate push does not, filters work, and a non-admin is redirected.Not covered: a successful symbol push through the NuGet API writes no audit line today, so it doesn't appear on the page either (web UI symbol uploads do).
Addresses #13