Ztron follows Tauri v2's ACL (access control list) model: deny by default — every command the frontend may call and every path/URL it may access must be explicitly granted in a capability.
capabilities/*.json are auto-loaded at app startup (default directory
./capabilities). Head of examples/hello/capabilities/main.json:
identifier is the capability's name, windows declares which window labels
it grants, and permissions is the list of permission strings.
Permission strings uniformly take the two-segment plugin:permission form —
the plugin (or core) name plus a specific permission. For example,
fs:allow-read-file grants only the fs plugin's readFile command;
core:default is the default set of core commands. Calls to commands not
listed are rejected by the backend even if that plugin's handler is
registered (verification anchor ACL_DENY_OK).
Beyond permissions, plugins involving files/network also have scope
constraints, all from hello's src/main.ts:
fsPlugin({ scope: psScope }), with the persisted baseline scope: { allow: ["$TMP/**"] }
— only the temp directory and its subtree are allowed.httpPlugin({ scope: { allow: [{ url: "https://api.github.com/*" }, { url: "http://localhost:*/*" }] } }).
Out-of-scope URLs are rejected outright (verification anchor
HTTP_SCOPE_DENY_OK).storePlugin({ scope: { allow: ["$TMP/**"] } }).The production CSP is configured via app.security.csp and injected into
pages by the framework; the dev environment can be configured separately with
devCsp, so that the dev server's loose policy never reaches production. The
legacy top-level csp key still works, but migrating to app.security.csp
is recommended.
适用版本:ztron 0.3.1