feat: per-key audit log dialog (opt-in) + AuditPinnedFilter primitive#57
Merged
Conversation
Three connected pieces:
1. Stable per-API-key identifier on every audit entry
- AuditEntry.CallerKeyId (Guid string of IApiKey.Key)
- TeamClaimTypes.ApiKeyId claim emitted by ApiKeyAuthenticationHandler
for both team and system keys
- AuditHelper.BuildEntry picks up the claim
- AuditEntryEntity (Mongo) round-trips the field
- AuditQuery.CallerKeyId + MongoDbAuditLogger.Eq filter
2. AuditPinnedFilter primitive on AuditLogView
- Public record with CallerKeyId / CallerType / TeamKey /
CallerIdentity / Feature / Action
- [Parameter] PinnedFilter on AuditLogView
- When set, BuildQuery force-injects the pinned values
(overrides any local _filterX state)
- Matching top-bar controls render disabled
- Info banner above the filter row shows the pinned scope so the
user always sees the context
3. Opt-in row button on ApiKeyView and SystemApiKeyView
- [Parameter] ShowAuditLogButton (default false) — existing
consumers see no UI change
- When true, an additional manage_search button per row opens a
wide Radzen dialog hosting <AuditLogView> with CallerKeyId +
CallerType=ApiKey pinned
8 new tests; 263 total passing.
…ositioning - ApiKeyView: actions column width now computed — base 180px, +40 for AdvancedMode (delete), +40 for ShowAuditLogButton - SystemApiKeyView: actions column 220px → 260px when ShowAuditLogButton is on - Dialog options switched from 'min(1100px, 95vw)' (the CSS min() function was being interpreted literally and pushed the dialog off-screen) to plain '90vw' / '85vh'. Added Draggable=true so the user can move the dialog if needed; Resizable=true was already set.
CodeQL scan ran successfully but upload of SARIF results to GitHub Code Scanning failed with: "Requires authentication ... contents: read, security-events: write" Workflow-level permissions are set, but the github/codeql-action/analyze upload step doesn't always pick them up reliably. Add an explicit permissions block on the security job: - contents: read - security-events: write - actions: read Matches the recommended setup in the codeql-action README.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
Three connected pieces that together let an admin click an API-key row and see the audit history scoped to that specific key — without juggling filters in
/developer/audit.The reusable middle piece (
AuditPinnedFilteron<AuditLogView />) also unblocks future audit-for-team / audit-for-user dialogs without further plumbing.Stack changes
1. Stable per-API-key identifier (Tharga.Team / Tharga.Team.Service)
AuditEntry.CallerKeyId(Guid string ofIApiKey.Key)TeamClaimTypes.ApiKeyIdclaim emitted byApiKeyAuthenticationHandlerfor both team and system keysAuditHelper.BuildEntryreads the claim and populates the entryApiKeyAuthenticationHandler.LogAuthEventwrites it directly fromIApiKey.KeyAuditEntryEntity(Mongo) round-trips the fieldAuditQuery.CallerKeyIdfilter applied asEqinMongoDbAuditLogger.QueryAsync2. AuditPinnedFilter primitive (Tharga.Team.Blazor)
New public record with the dimensions worth pinning:
<AuditLogView PinnedFilter=... />:AuditQuery(overrides any local filter state)RadzenSelectBarcontrols3. Opt-in row button (Tharga.Team.Blazor)
[Parameter] bool ShowAuditLogButtondefaults tofalse— existing consumers see no UI change. When on, each row gets amanage_searchicon button that opens a wide draggable Radzen dialog (90vw × 85vh,Draggable=true,Resizable=true) hosting<AuditLogView PinnedFilter="@pinned" />withCallerKeyId+CallerType=ApiKeypinned. Actions column auto-widens by 40px when the button is shown.4. Sample wiring
Tharga.Platform.SampleenablesShowAuditLogButton="true"on both/api-keysand/system-api-keysso the feature is testable end-to-end.Tests
8 new (4 service-level —
ApiKeyIdclaim emission for team + system keys, plus shape checks; 4 component-shape —AuditPinnedFilterpublic surface,[Parameter]declarations on the views andAuditLogView). Full suite: 263 tests passing.Test plan