Table of Contents

Class AuditWriter

Namespace
FishMMO.ControlPanel.Services
Assembly
FishMMO-ControlPanel.dll

Writes an audit row from the current request's identity.

public sealed class AuditWriter
Inheritance
AuditWriter
Inherited Members

Remarks

Controllers do not call this. AuditActionFilter does, once per privileged write, which is what makes coverage structural instead of a matter of each author remembering. A controller that wants to say more about what it did assigns to AuditScope instead.

Everything about the actor comes from the authenticated principal, never from the request body. An operator must not be able to write a row attributing their action to somebody else, which is exactly what a client-supplied actor field would allow.

A failed audit write never fails the action. The action has already happened by the time this is called; refusing to answer would not un-happen it, and would leave the operator believing it had not worked. The failure is logged loudly instead, because a panel that cannot record what it does needs attention even though it can still act.

Constructors

AuditWriter(IAdminAuditService, IHttpContextAccessor, ILogger<AuditWriter>)

public AuditWriter(IAdminAuditService audit, IHttpContextAccessor accessor, ILogger<AuditWriter> log)

Parameters

audit IAdminAuditService
accessor IHttpContextAccessor
log ILogger<AuditWriter>

Methods

FailedAsync(string, string, string, string, string, string, object)

Records a refused or failed action.

public Task FailedAsync(string action, string targetType, string targetId, string targetName, string reason, string outcome, object details = null)

Parameters

action string
targetType string
targetId string
targetName string
reason string
outcome string
details object

Returns

Task

Remarks

Called as often as the success path, deliberately. An operator repeatedly failing to reach something is the more interesting record, and without these rows the log cannot tell "never tried" from "tried and was stopped".

SucceededAsync(string, string, string, string, string, object)

Records a successful action.

public Task SucceededAsync(string action, string targetType, string targetId, string targetName, string reason, object details = null)

Parameters

action string
targetType string
targetId string
targetName string
reason string
details object

Returns

Task