Table of Contents

Class PrivilegedRequestMiddleware

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

Wraps authorization: turns a step-up refusal into a 428, and records refusals the action filter never sees.

public sealed class PrivilegedRequestMiddleware
Inheritance
PrivilegedRequestMiddleware
Inherited Members

Remarks

It must be registered before UseAuthorization. Authorization short-circuits on failure and never calls its next, so anything registered downstream of it is simply not entered when it refuses. This middleware used to sit after it, which meant the 403-to-428 rewrite below never ran: an operator whose step-up window had lapsed got a dead-end "Forbidden" on every moderation action instead of being asked for a code, since the browser keys its step-up prompt on the 428.

The second job exists because AuditActionFilter is an action filter, and an action filter does not run when authorization refuses the request — so a refusal decided by policy left no trace at all. That is the gap this closes: an account probing endpoints it may not reach is precisely the pattern the audit log exists to make visible, and it is already what the in-game command gate records.

Reads as well as writes, since 2026-09-14: every Game Master and Admin action is tracked, and a refused look at something above one's level is as much a probe as a refused write.

A refusal is recorded even when the browser marked the request as an automatic refresh (X-Panel-Refresh: auto, see RefreshHeader). The action filter skips a marked read that it answered, because a page polling itself every few seconds would bury the log; this middleware never consults the header. A refused poll is a probe like any other refused request, the mark is the client's word and so worth nothing as an excuse, and refusals are rare enough that recording every one costs nothing. The header is only ever trusted for a read that was allowed; a write is recorded whatever it carries.

Constructors

PrivilegedRequestMiddleware(RequestDelegate)

public PrivilegedRequestMiddleware(RequestDelegate next)

Parameters

next RequestDelegate

Fields

HandledKey

Marks a request whose action ran, so it is not recorded twice.

public const string HandledKey = "fishmmo:audit-handled"

Field Value

string

Methods

InvokeAsync(HttpContext, AuditWriter)

Runs the rest of the pipeline, then inspects how it ended.

public Task InvokeAsync(HttpContext context, AuditWriter audit)

Parameters

context HttpContext
audit AuditWriter

Returns

Task