Repository navigation
RFC: sandboxed network + preset-install API for the plugin system (project.plugin) #15817
dcode
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
RFC: A scoped, sandboxed network + preset-install API for the PrusaSlicer plugin system
prusa3d/PrusaSlicer,project.pluginAPI (currently at3.0.0-alpha11, tagversion_3.0.0-alpha11)jedisct1/prusaslicer-lua-plugins-api-doc(community reference, tracks the same alpha),doc/Plugin_API.md(official, in-tree)filament-db) into PrusaSlicer without running a custom fork; (B) on-demand checks against a fixed public community database (e.g.OpenPrintTag/openprinttag-database) — see §3Table of contents
api.net1. Summary
The current plugin runtime (
project.plugin, alpha11) is deliberately a one-shot, offline, in-memory automation API: it can add geometry and edit the currently selected preset's numeric/enum values, and nothing else. It has no network access, no general file I/O, and no way to create or persist a new named preset. That's a correct default for a first release, but it rules out an entire class of legitimate plugins — anything that imports structured data from somewhere else (a local tool, a vendor's catalog, a self-hosted service, a community database) and turns it into a usable, persisted preset.This RFC proposes two narrow, opt-in, manifest-gated capabilities, general-purpose by design:
api.net— a bounded HTTP client, scoped per-bundle by named "endpoint slots" declared inmanifest.json(each either a fixed origin baked into the signed manifest, or a per-installation origin the user configures in PrusaSlicer's own Preferences), enforced in C++ (not Lua), with strict size/time/redirect limits.api.project:install_preset(kind, spec)— a way to hand structured preset data to PrusaSlicer's existing preset-import pipeline (the same code pathFile > Import > Import Config Bundlealready uses), instead of giving Lua any form of file-write access.Neither is filament-specific.
api.netis exactly as useful to a plugin that fetches a print-quality profile, checks a firmware compatibility table, or just displays remote data with no preset involved at all.install_presetis scoped bykindfrom day one ("filament"|"print"|"printer") even though Phase 1 (§11) only implements"filament"— that's a sequencing choice to ship something concrete first, not a design boundary. §3 walks through two illustrative uses to keep every design decision below answerable against a real constraint rather than a hypothetical, but the capabilities themselves are the point.Both are additive, versioned via the existing
required_apismechanism, and default to fully disabled unless a bundle explicitly declares and the user explicitly consents to them.2. Current state (what's actually blocked, verified against source)
Checked against
prusa3d/PrusaSlicerat tagversion_3.0.0-alpha11:src/slic3r-biz-lua/src/Slic3r/Biz/Lua/LuaEngine.cppopens onlysol::lib::base, table, math, string, removesdofile/loadfile/load, and restrictssetmetatable/getmetatableto table targets. Noio,os,package,coroutine,utf8— confirmed, this is not a documentation gap, it's what the engine constructs.src/slic3r-shared/src/Slic3r/App/Lua/PluginSystem.cpp(PackageRegistry::safe_require) resolves modules through aFilePathResolveFnthat is sandboxed to the entry file's directory (same mechanism backsrequire,load_stl,emboss_svg). There is no general filesystem entry point at all — not even read-only outside that directory.src/slic3r-shared/src/Slic3r/App/Lua/ProjectApi.cppexposesBedInstRef:printer_presets/print_presets/tool_print_presets/material_presets, each returning a liveDomain::ConfigBox&bound to the currently selected preset inside the current in-memory project. There is no method anywhere inProjectApithat creates a new named, persisted preset, or writes to the preset store PrusaSlicer uses for its dropdown lists.PluginSystem::finalize_run()runs the plugin synchronously, inline with the dialog-confirm callback, followed immediately byrequest_render()and an undo snapshot. There is no background execution model, no event loop, no callback registration — a network call bolted on naively would block the UI thread for its full duration.This matches the community doc's findings (
runtime-and-sandbox.md,known-limitations.md,api/configuration-and-hardware.md) and the officialdoc/Plugin_API.md's own "Security model" section, which states the restriction as a design choice, not an oversight:The goal of this RFC is to extend that boundary deliberately, not route around it.
3. Illustrative use cases
These are examples used to pressure-test the design, not the boundary of what §5–§8 are for — see §1.
A. A local, self-hosted filament catalog (e.g.
filament-db, typically run on the same machine or LAN —http://127.0.0.1:3456, or a hostname on the user's own network such asfilament-db.home.arpa). It holds the user's own filament catalog: vendor, type, cost, density, calibration values, per-spool tracking. It already generates PrusaSlicer-compatible preset data (GET /api/filaments/prusaslicer— a config-bundle-shaped payload;GET /api/filaments/:id/prusaslicer— a single preset). Today, the only ways to get that data into PrusaSlicer are:filament-db's author actually ships today, because no smaller surface exists).This case is characterized by: a private, user-specific host that varies per installation (there is no single correct default), plausibly reached over plain HTTP on a trusted local network, and a service the user runs and controls.
B. A public, community-maintained material database (
OpenPrintTag/openprinttag-database— ~14,000 YAML-defined materials from ~130 brands, compiled and served over HTTPS withAccess-Control-Allow-Origin: *athttps://database.openprinttag.org/, i.e. already designed to be fetched cross-origin by third-party tools).filament-dbitself already integrates this database today (see its "Browse OpenPrintTag DB" import flow) — but only insidefilament-db's own app, not as something a PrusaSlicer plugin could offer directly ("check for new/updated materials" as a Plugins-menu command).This case is characterized by: a single fixed, public, always-HTTPS origin that's the same for every installation, and — importantly for scoping this RFC — a user-triggered, on-demand check, never a startup or background sync. That framing costs nothing extra to support and requires no change to §4's non-goals: "Plugins-menu command the user clicks to check for updates" is exactly the one-shot execution model this RFC already assumes throughout.
Neither case is buildable as a plugin today. This RFC closes that specific gap — bounded outbound HTTP to origins the user and/or the signed manifest explicitly established — without opening PrusaSlicer plugins up to the general internet or the general filesystem. The two cases also usefully pull the design in different directions: (A) needs a per-installation, user-editable destination; (B) needs zero configuration and a fixed trust anchor. §5–§6 propose a manifest shape that supports both without collapsing them into one weaker model.
4. Goals / non-goals
Goals
LuaEngine::open_registry,PluginBundleMeta/required_apis,sol2usertype bindings) rather than introducing a parallel plugin runtime.Non-goals (this RFC) — unchanged by adding use case B
known-limitations.md's "No management or background APIs," and OpenPrintTag's "check for updates on demand" framing (§3B) fits this exactly, it doesn't stretch it.os/process/shell access, ever.filament-db's own PrusaSlicer fork is explicitly out of scope; that requires an event loop this RFC does not propose adding.5. Proposed manifest schema addition
The two illustrative use cases (§3) need different trust shapes for "where does this plugin talk to": OpenPrintTag is one fixed, public, always-HTTPS origin that's correct for every user;
filament-dbis a per-installation destination the user, not the plugin author, actually knows (http://127.0.0.1:3456on one machine,https://filament-db.home.arpaon another, some LAN IP on a third). A flatallowed_originslist signed into the manifest can express the first case but not the second — the plugin author cannot pre-declare a user's home-lab hostname.So instead of a flat origin list, the manifest declares one or more named endpoint slots. A slot fixes what the plugin can ask for the name of (signed, can't change without re-signing); it does not always fix the value — that's either baked in (
kind: "fixed") or left for the user to supply (kind: "user_configurable"), resolved by PrusaSlicer, not by plugin code, from a place plugin Lua code cannot write to.Extend
PluginBundleMeta(src/slic3r-shared/include/Slic3r/App/Lua/PluginBundle.hpp) with an optionalnetworkblock, parsed inload_meta_from_text(PluginBundle.cpp) using the existingSAFE_GET-style helpers:{ "id": "com.example.filament-sync", "name": "Filament DB sync", "version": "1.0.0", "min_slicer_version": "3.1.0", "author": "example-developer", "license": "MIT", "required_apis": { "project.plugin": "1.0.0", "network.fetch": "1.0.0", "preset.install": "1.0.0" }, "network": { "endpoints": [ { "id": "filament_db", "label": "Filament DB URL", "kind": "user_configurable", "default": "https://filament-db.example.com", "allow_private_http": true, "allow_untrusted_tls": true }, { "id": "openprinttag", "label": "OpenPrintTag Database", "kind": "fixed", "origin": "https://database.openprinttag.org" } ], "max_response_bytes": 5242880, "timeout_ms": 8000 } }id— a stable slot name, scoped to this bundle, referenced from Lua (§6) and from the settings UI (§10). Not a URL.label— human-readable text shown in Preferences and in the install-consent screen. This is what the user actually reads, so it's worth being a required field rather than falling back toid.kind: "fixed"— the base URL is exactly the manifest'soriginvalue, always. It is not user-editable in Preferences (there's nothing to edit — it's shown read-only, e.g. "OpenPrintTag Database:https://database.openprinttag.org(fixed by plugin)"). Must behttps://unless the fixed host is loopback (rare for a "fixed" slot, but not disallowed — a plugin could legitimately always talk to a sibling process on the same machine).kind: "user_configurable"—defaultis what's used until the user changes it (documentation and screenshots should showfilament-db.example.com, never a real user's LAN hostname). The current value lives in PrusaSlicer's ownAppConfig, keyed by(bundle id, endpoint id), editable via Preferences (§10) or a native "Configure…" command the plugin can surface in its own menu entry (still a PrusaSlicer-rendered dialog, not something the plugin's Lua paints — see §10's UI-spoofing note). A plugin update or re-run never resets a user's configured value; only the user, editing Preferences, can.scheme://host:port— it may carry a path prefix, e.g. a user sitting behind a reverse proxy that path-routes multiple internal services under one domain might sethttps://home.example.com/filament-dbas this slot's value.fetch'spath(§6) is appended to whatever base URL is currently configured; the security checks below (scheme,allow_private_http,allow_untrusted_tls) apply to the base URL's origin component (scheme + host + port) — the path prefix, if any, is just a fixed string PrusaSlicer concatenates on, not a trust boundary by itself.allow_private_http— declares that this slot is allowed to resolve to a private-use address over plain HTTP (see §6's revised origin-validation rules); auser_configurableslot that's realistically always going to be a public HTTPS SaaS endpoint should leave thisfalse/absent so the C++ layer still hard-blocks a user accidentally (or a plugin's UI text talking them into) pointing it athttp://some-public-host.allow_untrusted_tls— declares a ceiling, not an activation: this slot is allowed to offer the self-signed/private-CA path at all (see §6). It does not, by itself, cause PrusaSlicer to accept an untrusted certificate for anyone. Whether a given installation actually uses that path is a separate, per-user, per-slot decision made in Preferences (§6, §10) — the plugin author doesn't know, and shouldn't get to decide, whether any particular user'sfilament_dbdeployment legitimately runs a self-signed certificate or whether an untrusted cert there would be a red flag.allow_untrusted_tls: false/absent removes the option from that user entirely (no toggle shown), which is the right default for a slot with no plausible reason to need it. Independent ofallow_private_http: a slot can allow one, the other, both, or neither.max_response_bytes/timeout_ms— plugin-declared ceilings, clamped server-side (C++) to hard maximums (e.g. 16 MiB, 30 s) regardless of what the manifest claims, so a malicious manifest can't declare absurd values and a well-behaved one still gets predictable limits.Two new
required_apisentries (network.fetch,preset.install) rather than overloadingproject.plugin, so a plugin that only needs geometry/preset-editing (today's whole surface) is unaffected, and PrusaSlicer can refuse to load a bundle that asks for capabilities the installed version doesn't implement (the existing "unknown API name makes the manifest invalid" behavior — seeknown-limitations.md— already does most of this work; enforcement of version is the one gap flagged there and worth closing alongside this change).This is a pure additive parse: existing manifests with no
networkkey are unaffected,networkabsent ⇒api.netis not registered into the Lua state at all (not present-but-empty — genuinely absent, sopcall(function() return api.net end)behaves identically to today).Because
PluginBundle::verify()already hashes and signs the entire bundle directory (manifest.txtchecksum +manifest.signRSA signature,Biz::Crypto), thenetworkblock — critically, the set of endpointids and each one'skind/allow_private_http/allow_untrusted_tls— is covered by the existing signature. A plugin cannot invent a new slot at runtime, turn afixedslot into auser_configurableone, or flipallow_private_http/allow_untrusted_tlson, without invalidating the signature. What a plugin update can legitimately do (author re-signs, user updates the plugin) is add new slots or change afixedorigin; what it can never do is silently repoint a slot the user already trusted with a value — the user's stored value for a given(bundle id, endpoint id)is simply orthogonal to the manifest and untouched by a plugin update, addressed further above.6. Proposed Lua API:
api.netMirrors the
ProjectApiregistration pattern (a small C++ class with aregister_api(Biz::Lua::LuaEngine&)method, composed into the state alongsideProjectApiandPackageRegistryinPluginSystem::finalize_run()). Crucially, Lua never constructs or passes a full URL — it names a manifest-declared endpoint slot (§5) and a path, and PrusaSlicer resolves the slot to whatever origin is currently in effect (the manifest'soriginfor afixedslot, or the user's configured value for auser_configurableone):If
endpointdoesn't name a slot declared in this bundle'smanifest.json,fetchraises a Lua error immediately — there's no way to reach a slot another plugin declared, and no way to reach anywhere the manifest didn't name at all, regardless of what the user has configured for other plugins' slots.Path handling and reverse proxies. The request URL is
base_url_of(endpoint) .. path, wherebase_url_ofis the slot's current base URL (§5 — may itself carry a path prefix, e.g.https://home.example.com/filament-db, for a user behind nginx/Traefik-style path routing) andpathis what the plugin passed. Before concatenating,pathis validated: must be a relative path starting with/, must not itself contain a scheme (a literal"://") or a..path segment. This isn't about the origin check below — host/port/scheme are already pinned by the resolved base URL regardless ofpath— it's specifically to stop a plugin'spathfrom walking a reverse-proxied deployment back out of its intended sub-path and onto a sibling service proxied at another path on the same host (e.g.path = "/../other-service/admin"reaching something the base URL's prefix was supposed to scope the plugin away from). Query strings and fragments inpathare untouched by this check.Design constraints, enforced in C++, not advisory:
Slot resolution, then an origin check, happen before DNS resolution. PrusaSlicer looks up the current base URL for
endpoint(manifestoriginforfixed;AppConfigvalue, falling back to manifestdefault, foruser_configurable), then validates its origin component (scheme + host + port — the path prefix, if any, isn't part of this check) before ever connecting:kind: "fixed": must behttps://(checked at manifest-parse time — anhttp://fixed origin fails to load the bundle at all, same class of error as an invalid semver today).kind: "user_configurable"withallow_private_http: false(or absent): the current value (default or user-set) must behttps://, checked every time it's read, not just once — so a slot that was HTTPS at install time can't later be silently switched to HTTP by an unrelated AppConfig edit path.kind: "user_configurable"withallow_private_http: true: plain HTTP is accepted only if the resolved address is private-use (RFC1918, ULA IPv6fc00::/7, loopback, or a.local/mDNS name) — checked after DNS resolution, not by pattern-matching the hostname (a home-lab hostname likefilament-db.home.arpacan't be recognized as "private" from its spelling alone, only from where it actually resolves). A hostname that resolves publicly is rejected over plain HTTP even on anallow_private_httpslot, full stop — see the next bullet for the one narrow, explicit exception.169.254.0.0/16/fe80::/10(link-local, including cloud-provider metadata endpoints) is hard-blocked unconditionally for every slot kind, with no user-override path — there is no legitimate reason to allow it, and the failure mode of allowing it (cloud-hosted desktop sessions, CI runners) is severe enough not to leave a click-through.TLS validation, and trust-on-first-use pinning for untrusted-CA HTTPS. Standard system-trust-store validation applies to every HTTPS connection by default — same as any other HTTPS client, no exceptions, regardless of
allow_private_http. A locally-run HTTPS service with a self-signed or private-CA certificate (a very common shape for home-lab deployments — no public CA is going to issue a certificate forfilament-db.home.arpa) is a different problem from plaintext HTTP, and needs two independent things to be true before PrusaSlicer will ever accept one, not one:allow_untrusted_tlsistrue(§5) — the plugin author is asserting this slot plausibly points at a self-hosted service, reviewed like any other manifest claim at install-consent time.Only when both are true does a failed system validation lead anywhere other than a hard failure. With the toggle on, an untrusted certificate triggers a native dialog showing its fingerprint, subject, issuer, and validity dates, and asks the user to explicitly trust that exact certificate — not "trust this CA," not "disable validation for this slot." This is the same shape as SSH's default trust-on-first-use behavior: an unrecognized host key prompts once and is then remembered (
~/.ssh/known_hosts); a changed key on a previously-trusted host refuses outright rather than prompting again. PrusaSlicer's version: the accepted certificate's SHA-256 fingerprint is pinned inAppConfigalongside the slot's value; every laterfetchon that slot compares the served leaf certificate against the pinned fingerprint, and any mismatch — including a legitimate-looking renewal — fails the request with a clear "certificate has changed since it was trusted" error, requiring the user to go back to Preferences and re-confirm rather than being silently re-prompted mid-fetch. Once pinned, hostname and expiry mismatches on that specific certificate are not separately enforced — the user is trusting one exact key, not "any validly-issued cert for this name," so those checks would be redundant. Changing the slot's configured value, or switching the Preferences toggle back off, clears any existing pin for it.allow_untrusted_tlsnever applies tofixedslots (§5) — a plugin author declaring a fixed origin is expected to run it behind a real, publicly-trusted certificate, and there's no per-user Preferences entry for afixedslot to hang a toggle on in the first place.No redirect following. A 3xx response is returned to Lua as-is (
response.status = 302, etc.) with theLocationheader available; the plugin can inspect it, but a freshfetchcall can only ever target a declaredendpointagain — there is nofetch-by-raw-URL to redirect into, so an off-origin redirect target is simply unreachable rather than something that needs a special re-check. This is a stronger position than a flat-origin-allowlist design would give: afetch{url=...}shape checked against an allowlist still needs an explicit redirect re-check rule; naming endpoints instead of accepting URLs removes that whole bypass class by construction.No cross-origin credential passthrough.
CookieandAuthorizationheaders set inheadersare only ever sent to the one origin the namedendpointcurrently resolves to — there is no mechanism by which they could reach a different origin, sincefetchcan't target one.Method allowlist:
GET/POSTonly in v1. NoPUT/DELETE/PATCH— a plugin that needs to mutate a remote resource is a bigger trust decision than "import my data," and can be revisited once the read-only case is proven out.Response cap: streamed with a byte counter, aborted the instant
max_response_bytes(clamped to the hard ceiling) is exceeded, rather than buffered-then-checked.Timeout: hard wall-clock timeout via the existing connection layer PrusaSlicer already uses for update checks / profile downloads (there is precedent here — PrusaSlicer already makes outbound HTTPS calls for its own updater; this reuses that HTTP client rather than introducing a new one).
fetchis a synchronous Lua call from the script's point of view, but see §8 for how that's kept from freezing the UI thread.7. Proposed Lua API: a general preset-install capability
Rather than exposing any filesystem write primitive to Lua — which would reopen the exact hole the sandbox exists to close — this proposes exposing the existing, already-audited preset-bundle-import code path (the C++ that backs
File > Import > Import Config Bundle) as a narrow, structured Lua entry point. It's one capability across preset types, not a filament-only feature:kindmakes this one general entry point rather than three near-duplicate ones (install_filament_preset,install_print_preset,install_printer_preset) — the underlyingPresetCollectionmachinery already has to know which preset family it's touching, so this is a thin pass-through, not new per-kind logic. Phase 1 (§11) implementskind = "filament"only — not because print/printer presets are architecturally different, but because filament is the simpler schema to validate first;kind = "print"/"printer"should raise a clear "not yet implemented" Lua error rather than being silently accepted and dropped.Key differences from
ConfigBox:set:PresetCollection's save/import machinery (the same layer the config-bundle importer uses) to create or update a named preset in the user's preset store, visible in the dropdown after the call returns (or after the next preset-list refresh, whichever the existing import path already does — this RFC doesn't need to reinvent that, only route into it).ConfigBoxsetter, it inherits that pipeline's existing support for string types (filament_colour), so this also incidentally fixes the "boolean/string/vector fields aren't settable" gap noted inknown-limitations.md— for this entry point.ConfigBox:set's narrower behavior on the currently selected preset is unaffected and unchanged.on_conflictis mandatory, not defaulted, specifically becauseknown-limitations.mdalready documents once that "installation replacement is not transactional" for the ZIP-plugin-install case — this API should not repeat that ambiguity for presets."rename"should append a numeric suffix the same way the GUI does today on a name collision.required_apisgate (preset.install, above) distinct fromproject.plugin, since it's a materially different trust level (persists after the plugin run ends, visible to every future project) from "edit the config of the object I'm about to add."8. Execution model: keeping the UI thread unblocked
PluginSystem::finalize_run()today runsplugin.execute(lua, params)synchronously on the thread that just handled the "Run" button, then immediately callsrequest_render()and takes an undo snapshot. A blocking HTTP call inside that path — even a well-behaved 200ms localhost call — is a UI freeze, and a slow/hanging server (or a plugin that callsfetchfive times) makes it worse.The codebase already has the pieces for a clean fix:
slic3r-jthreadexists as its own module — there is precedent for cooperative worker-thread use elsewhere in the app.PluginDialogalready owns the "Run" confirmation flow and is already wired throughWithListeners<IPluginRescanListener, IPluginInstallationListener>for async-ish install feedback.Proposed change to
finalize_run(): when (and only when) a bundle'srequired_apisincludesnetwork.fetch, run the Lua execution on a worker thread (jthread) instead of inline, and show a small non-blocking "Running<plugin name>… [Cancel]" modal on the UI thread until the worker signals completion, error, or the manifest'stimeout_mselapses (enforced independently by the C++ side, not trusted to the plugin behaving). Plugins that don't declarenetwork.fetchkeep today's exact synchronous path — zero behavior change for the ~100% of plugins that don't need this.This also naturally caps "how long can a network-using plugin run" at the process level, rather than only at the per-
fetchtimeout — a plugin issuing 50 sequential 1-second fetches doesn't get to run for 50 seconds unnoticed.9. Security / threat model summary
fetchonly ever targets a manifest-declaredendpointslot's currently resolved origin, checked before every request (not cached indefinitely); non-allow_private_httporigins must be HTTPS; private-HTTP resolution is checked post-DNS against actual private-use ranges, not the hostname's spellingLocationheader), never auto-followed; there is nofetch-by-raw-URL at all, so a plugin cannot construct a follow-up request to the redirect target even deliberately — it can onlyfetcha declaredendpointagainPluginBundle::verify); any edit invalidates the signatureIPluginInstallationListenerAuthorization/Cookieheaders travel only to the one origin the namedendpointcurrently resolves to; there is no request shape that lets one slot's credentials reach a different slot's originon_conflictmandatory;install_presetcan create/update by exact name only, no glob/bulk deleterequired_apisgate (network.fetch,preset.install) fromproject.plugin; absent ⇒api.netnot registered, not merely denied at call timefetchonly accepts a manifest-declaredendpointid, never a raw URL; the set of ids, each one'skind, andallow_private_httpare inside the signed bundle and can't change without invalidating the signatureuser_configurableslot at plaintext non-private host (accidentally or otherwise)allow_private_httpunset); when explicitly enabled by the manifest, still requires the resolved address to be private-range, or an explicit per-value "I understand this is unencrypted" click that's cleared the instant the value changes169.254.169.254etc.)allow_private_httpallow_untrusted_tlsceiling + a per-slot Preferences toggle the user must switch on, off by default) before a TOFU-pinned exact-certificate flow (SSH-known_hosts-style) ever engages; any later mismatch fails closed rather than silently re-trustingallow_untrusted_tlsonly controls whether the Preferences toggle is offered; the toggle itself is off by default and the user — who actually knows their own network — must switch it on before any untrusted certificate is ever acceptedpathwalks a reverse-proxied deployment out of its intended sub-path (path = "/../other-service/...")pathis validated as a traversal-free relative path before being appended to the slot's configured base URL;..segments and embedded schemes are rejected outrightExplicitly not solved by this RFC, flagged for reviewers: a plugin with a declared loopback origin can still talk to any server a user chooses to run on that port, including one impersonating
filament-db. That's an acceptable residual risk for a same-machine companion-app integration (it's no different from installing any other local tool), but should be called out plainly in the install-consent UI text, not left implicit.10. Install-time consent UI, and ongoing configuration
Two distinct moments need a native (non-Lua-rendered) UI surface — install-time consent is a one-time gate, but §5's
user_configurableslots need a persistent, revisitable settings surface too, which is new relative to the original single-consent-screen design.Install-time consent.
PluginSystem::install()already routes success/failure throughIPluginInstallationListener. Add a pre-install confirmation step (beforem_registry.install(...)is called) that surfaces, verbatim from the parsed-but-not-yet-installed manifest:required_apisin human terms, each endpoint slot shown by itslabel, not its rawid, e.g.:.pemmanually, perknown-limitations.md§"Installing an author key is manual" — this is one more explicit, deliberate step in the same spirit, not a new UX pattern).Ongoing configuration (new). For each installed bundle with at least one
user_configurableendpoint, PrusaSlicer surfaces a settings panel — under Preferences > Plugins ><bundle name>, and additionally reachable from the Plugins menu itself if the bundle wants to surface it inline (a plugin'sinfocan flag one of its commands asconfigures_endpoints = truerather than a normal run command; selecting it opens the same native panel instead of the plugin's execute() param dialog). Two invariants keep this safe regardless of how it's reached:network.endpointsentries. This is what stops a malicious plugin from painting a convincing-looking-but-fake "Preferences" dialog to phish a value.Per-value state — the base URL itself, the "I understand this is unencrypted" flag (§6), the "allow self-signed/untrusted certificate" toggle (§6, shown only when the slot's manifest sets
allow_untrusted_tls: true, and off by default even then), and any pinned certificate fingerprint — lives inAppConfigkeyed by(bundle id, endpoint id), so it survives plugin re-installs/updates that don't remove the slot, and is wiped only if the user removes the plugin or explicitly resets that slot's configuration. The same Preferences panel is where a pinned certificate would be shown and could be manually cleared, or the toggle switched back off — either one forces the trust-on-first-use flow again on the nextfetchthat needs it.11. Phasing
network.fetchwith the endpoint-slot model from the start (bothfixedanduser_configurable— the two motivating use cases need both, and retrofittinguser_configurablelater would be a breaking manifest-schema change), synchronous-but-backgroundedfetch,preset.installfor filament presets only (print/printer presets deferred — filament is the concrete motivating case and has the simplest schema).kind = "print"/"printer"oninstall_preset; considerPUT/DELETEmethods onapi.netif real plugins demonstrate need; consider raising the non-loopback-HTTPS case from "supported" to "documented with examples" once Phase 1 ships and gets real-world use.12. Alternatives considered
io/osdirectly, let plugin authors sandbox themselves. Rejected — this is exactly the boundarydoc/Plugin_API.md's "Security model" section says is intentional; reopening it defeats the point of a signed-bundle plugin system.filament-dbitself took). This remains a completely valid today answer and isn't mutually exclusive with this RFC — it's simply a different, already-available integration point that doesn't require any PrusaSlicer changes. This RFC exists because "a plugin can do it" is a materially better experience (one install, inside the app, using the app's own trust/signing model) than "run a second background process," for anyone the smaller-scoped API is sufficient for.13. Open questions for maintainers
PresetCollection's save path (backingFile > Import > Import Config Bundle) actually safe to invoke off the UI thread, or doesinstall_presetneed to marshal back onto the UI thread even thoughfetchitself runs on a worker? (This RFC assumes the latter is fine — do the fetch on the worker, apply the resulting preset on the UI thread after — but that's an assumption, not verified against the preset-save code.)fixedorigins (e.g.database.openprinttag.org) be pre-approved by Prusa as "verified integration" endpoints shown differently in the consent UI (similar to howauthorized_authors/<author>.pemis a manual trust step today), or should everyfixednon-loopback origin always go through the same full install-consent flow with no shortcuts? This RFC assumes the latter (no shortcuts) as the safer default.required_apisversion enforcement (currently parsed but not checked —known-limitations.md§"Compatibility fields are not enforced") a prerequisite for shippingnetwork.fetch/preset.install, so that a future breaking change to this API can't silently run against an older, differently-behaved plugin? This RFC recommends treating it as a prerequisite.configures_endpoints = true(§10) to open the native settings panel inline, or is routing everyone through Preferences simpler to implement and audit for a first version, with the inline shortcut added later once the pattern is proven? This RFC has a mild preference for shipping Preferences-only first — one settings surface to review is a smaller change than two.AppConfigalongside the value (cleared only when the value itself changes) an acceptable balance of friction vs. nagging? This RFC assumes persisted-until-value-changes, consistent with how most OS-level "trust this network" prompts behave, but it's a real UX/security trade-off worth maintainers weighing in on rather than a settled default.(bundle id, endpoint id), or would it be worth keying the pin store by resolved host:port instead, so that two different plugins pointed at the same self-hosted service (or the same plugin reinstalled under casual re-signing) don't each make the user click through the trust dialog separately? This RFC defaults to the stricter per-slot scoping (no implicit trust sharing between plugins, even for the same physical host) as the safer starting point, with host-scoped sharing as a possible later convenience improvement, not a Phase 1 requirement.14. Proposed Next Steps
Asked of maintainers:
project.pluginshould grow toward at all, or is "stay offline and file-scoped" the intended long-term shape for this API? Everything else here is moot if the answer is the latter, so this is the one thing worth resolving before any implementation work.PresetCollection's save path is safe off the UI thread — determines how big theinstall_presetimplementation is) and item 3 (required_apisversion enforcement as a prerequisite — determines whether this can ship before or must ship alongside that fix).What we can do next, given a green light:
doc/Plugin_API.mdand §2's findings directly so maintainers don't have to re-derive "what's currently possible" from scratch.PluginApiType::Networkend-to-end behind a build flag: manifest parsing fornetwork.endpoints(§5) →required_apisgate → aNetworkApiclass mirroringProjectApi'sregister_apipattern → origin/TLS/path-prefix enforcement (§6) → the worker-thread execution change infinalize_run()(§8). Scoped deliberately to the network half alone first — it's independently useful (a plugin that fetches and just displays data needs nothing from §7) and is a smaller, more reviewable unit than shipping both halves together.install_preset(§7) once §13.1's threading question has an answer, since that answer determines its implementation shape.All reactions