adminapi

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Package adminapi serves merlon's Tier-2 dynamic config over Caddy's admin API (spec §8): rule CRUD with ETags and an audit log, plus the settings lanes, workers with their schedules and assets, the fp_block and fp_intel lanes, live inspection over SSE, configuration export and the web console SPA — a non-exhaustive enumeration; API.Routes is the one pinned route table. Request/response JSON keys are FROZEN wire contracts (style.md — FROZEN surfaces): copy them character-for-character from the defining struct in this package, never re-derive one in prose. Mounted automatically via the admin.api module namespace; reachable only wherever the admin listener is bound (loopback by default).

Index

Constants

View Source
const (
	ConsoleCSP           = "" /* 174-byte string literal not displayed */
	ConsoleXFrameOptions = "DENY"
	ConsoleNosniff       = "nosniff"
)

Console security header trio (S2-D1, red-team 2026-11-09 F1/G1), served on every response serveConsole writes and nothing else on the admin mux. The built bundle is inline-free for SCRIPTS (single external module script, linked CSS, no url(data:) in the CSS), so script-src 'self' needs no nonces, hashes, or 'unsafe-inline' — the XSS containment stays strict. img-src keeps data: on cited evidence: the Workers view's CodeMirror injects runtime url('data:image/svg+xml,…') backgrounds (console/dist/assets/Workers-*.js, cm-highlightTab) — dropping data: would break that rendering. style-src carries the same evidence-based carve-out ('unsafe-inline'): CodeMirror 6's style-mod module injects its 10,869-char base theme as a runtime <style> element (console/dist/assets/Workers-*.js; mounting JsonEdit on Overview's cards or the Workers editor), and style-mod's only standards-compliant alternatives are per-response nonces — which D1's build-verified inline story explicitly rules out — or pinning a content hash that changes on every console rebuild. Live proof: the M23 wave-2 browser walk blocked exactly this blob (sha256 pBliVWB4…, console error on #/workers and on every Overview pin that mounts an editor), violating D1's anti-goal "a CSP that silently breaks any console view"; capture.py's animation-kill add_style_tag (the committed PNG re-proof pipeline) is blocked identically. Styles carry no script execution; inline-style CSS exfiltration needs a navigation/form sink, and form-action 'none' plus base-uri 'none' close both. frame-ancestors 'none' is the operative law; X-Frame-Options: DENY covers legacy engines. Task 5 (e2e) imports these.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API implements caddy.AdminRouter (module id admin.api.merlon).

func (API) CaddyModule

func (API) CaddyModule() caddy.ModuleInfo

CaddyModule returns the module info.

func (API) ID

func (API) ID() string

ID returns the module id.

func (*API) Provision

func (api *API) Provision(ctx caddy.Context) error

Provision binds the module logger so handlers can surface failures that cannot be reported to the client (audit-append errors, I2). Caddy v2.11 provisions admin.api router modules before registering their routes, and Routes() is called on this same instance, so method-value handlers always see a bound logger.

func (*API) Routes

func (api *API) Routes() []caddy.AdminRoute

Routes implements caddy.AdminRouter. Patterns use Go 1.22+ ServeMux syntax; more-specific static segments (e.g. /rules/reorder) win over wildcards automatically.

func (*API) ScopedHandler

func (api *API) ScopedHandler() http.Handler

ScopedHandler builds the scoped mux: every scopedRoutes() entry replayed onto a stdlib ServeMux (the same mux flavour caddy v2.11 registers Routes() onto) with the whole `scoped` chain in front of each handler, and caddy's AdminHandlerFunc error adapter reproduced so both planes answer returned errors identically. P1 mounts it from tests and from operator-authored wiring that needs an http.Handler; the returned handler resolves the merlon app per request exactly like the loopback plane (resolveApp), so it must be reached only where caddy.ActiveContext() carries a provisioned merlon app.

type TokenSiteScopes

type TokenSiteScopes struct {
	Site   string
	KeyID  string
	Scopes []string
}

TokenSiteScopes is the verified-credential handoff (name FROZEN by the brief) — what Task 6's middleware reads when verifyBearer says ok: Site is the snapshot the row was found in (already canonical — the same key the {site} path binding will NormalizeSite its segment into), KeyID is the non-secret lookup index (audit-safe per §7.2 "keyid only"), and Scopes is the row's frozen set (read|write|workers). The secret never leaves verifyBearer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL