namespace OpenWaf.Edge.Admin;
///
/// The operator's console: one page, served by the edge itself, over the
/// endpoints in . It adds no decision logic — every
/// action on the page is one call to an endpoint that already exists.
///
/// Two properties are inherited from the admin API rather than invented here,
/// and both are load-bearing:
/// * /admin is on the always-pass list, so an operator who is themselves
/// blocked can still reach the page that clears it;
/// * the always-pass surface is never observed, so fumbling the page cannot
/// build a streak against the operator.
///
/// The token is never in a URL. A token in a query string survives in proxy
/// logs, browser history and Referer headers, which is exactly how an admin
/// token on a public edge leaks. It is typed into the page, kept in
/// sessionStorage for the tab, and sent as a header.
///
/// No external assets: the runtime image is distroless and the edge is often
/// the thing standing in front of a site that is under attack. A page that
/// needs a CDN is a page that fails at the moment it is wanted.
///
internal static class AdminConsole
{
public static IEndpointRouteBuilder MapAdminConsole(this IEndpointRouteBuilder app)
{
// One endpoint, not two: "/admin" and "/admin/" are the same route to the
// matcher and registering both is an AmbiguousMatchException at request
// time (found by a test, not by reading). The catch-all is deliberate —
// this is a single page, so a mistyped subpath should show the page
// rather than be proxied to an upstream that has never heard of it.
app.MapGet("/admin/{**rest}", () => Results.Content(Page, "text/html; charset=utf-8"));
return app;
}
private const string Page = """
openwaf — operator
openwaf
no token
—
Bans and blocks
source
provenance
reason
live until
last
Allow entries
match
note
expires
Sources the edge is watching
source
consec.
refusals
last status
path
geo
Streaks standing in this edge
source
consecutive
server errors
last status
path
geo
last seen
Alerts — what the edge wants a human to look at
kind
source
count
last
when
Countries seen
code
sources
refusals
refusals vs the busiest
rule
Every action here is one call to the admin API. The page decides nothing.