2.6 KiB
Plugin routes declare their access
Website factory plugins are written by a model and reach customer sites with
automatic checks as the only gate (orchestrator ADR 0064, ADR 0085). In the
WO-088 live runs a generated plugin served stored quote requests (names,
emails, phones, addresses) from a plain http.ServeMux route with no
authentication, and its public form accepted any POST with no captcha. The
SDK gave a plugin no way to say who a route is for, so check-safety had
nothing to require.
Decision: the new route package serves a plugin's HTTP routes under
/api/plugins/<name> with an access level on every route.
route.New(pluginName)returns anhttp.HandlerforRegistration.HTTPHandler.Handle(method, path, access, h)takesroute.Public,route.Visitororroute.Admin. Visitor and Admin routes rebuild the caller from the host's trusted identity headers and answer 401 or 403 before the handler runs; Admin needs theadminorsuperadminrole. A Public route may only be GET or HEAD; any other public method panics at registration.Form(path, h)is the one way to serve a public POST. It answers 403 unless the host verified the request's captcha (auth.CaptchaVerified), 429 pastFormBurstsubmissions at once andFormsPerMinuteafter that per plugin instance, and caps the body atMaxFormBytes.CaptchaWidget()returns the CMS captcha widget markup, so a Go-rendered block can put it inside its form.
check-safety requires this package for factory-generated plugins and warns on hand-built routers in first-party plugins.
Rejected: a host-side access declaration in the manifest. It would need an ABI change and a CMS release for every route shape, and the guest still has to check identity because context does not cross the ABI. The submission limit lives in the guest because the host has no per-route limiter for plugin routes; it counts per wasm instance, so the real ceiling is the pool size times the limit. A per-client limit needs a host-verified client address and is recorded as a remaining gap in orchestrator ADR 0085.
Consequences:
- Released in v0.3.12. The plugin builder image, its module cache and the factory prompt bundle move to v0.3.12 together.
- Generated plugins get a 401, 403, 405 or 429 from the router itself, which the runtime acceptance harness checks route by route.
Keywords: route, route.New, route.Handle, route.Form, route.Public, route.Visitor, route.Admin, CaptchaWidget, FormsPerMinute, FormBurst, MaxFormBytes, access level, plugin HTTP routes, captcha, rate limit, public form, WO-097, website factory, generated plugin