Repository navigation
Non-super editors can work with assets again, string fields stop accepting values
that break a record, and tools from other packages can be recommended by discovery.
Some writes that used to succeed are now refused: a list, boolean or object sent to
a string field, an asset copy by a caller without upload {container} assets, and a
container get/update/delete whose handle the resource policy denies.
Added
- Extra tools can be recommended by
statamic-system-discover(#76, thanks @illia-sapryga) — a router another package registers can returndiscoveryKeywords(); discovery scores them like the built-in routers' keywords and recommends the tool with the first sentence of its description as the reason (discoveryReason()to change it) and the right access path (listed_in_catalogorvia_execute_tools). Before, discovery only ever recommended the built-in routers, so an intent such as "change a page's SEO title" pointed atstatamic-entriesandstatamic-globalseven on a site whose SEO package registered its own tool.discoveryKeywords()returns none by default, so existing tools are unaffected. A switched-off tool is never recommended, a keyword counts once however often it is listed, and a tool whose keywords or reason throw is skipped rather than failing discovery. See Extending: tools.
Security
- Container
get,updateanddeletecheck the resource policy on the container they act on (#79) — the policy was checked ondata.handlewhen present, while those handlers act on the top-levelhandle, so an allowed name indata.handlelet a caller read, change or delete a container the policy denies. Onlycreatenames its container indata.handle. - Container
getchecks the permission on the container it returns (#79) — the permission was keyed oncontainerwhile the handler readhandle, so a caller allowed to view one container could read another's configuration. - Asset
copyrequiresupload {container} assets(#79), as Statamic's own duplicate action does. It used to requiremove, so an editor who could move but not upload could create new assets.
Fixed
- Editors with per-container asset permissions can use
statamic-assetsagain (#78, #79) — every write handler re-checked a permission Statamic does not have (create assets,edit assets,create asset_containers, …) after the outer check had already enforced the real one (upload {container} assets,configure asset containers, …), so only super admins could upload, update, move, copy or delete assets, or manage containers. The redundant inner checks are gone; the per-container checks still apply. configure asset containerscovers every asset action (#79), as it does in Statamic'sAssetPolicy. A per-container action used to demand the per-container permission alone, so a container admin was refused uploads and edits.- Container
listshows the containers the caller can view (#78, #79) — it requiredconfigure asset containersand then returned every container, ignoring the resource policy. It now lists each container the resource policy allows reading and the caller can view. - String fields refuse values that are not strings (#77, #80) — a
text,textarea,slug,markdown,color,linkorvideofield had no input check, and Statamic's own rules let a list through (requiredpasses for a non-empty array). Sotitle: ["a", "b"]was saved and the entry broke when it was rendered. These fields now take a string, cast a number to one, and refuse anything else with an error naming the field, at every level of a record. A value already stored does not block updates to other fields, and a sanitizer registered throughFieldtypeExtensionsreplaces the built-in check. - Field errors inside sets name the full path (#80) — a bad value in a replicator set, grid row, bard set or group was reported by its own handle alone (
[text]); it is now reported as[page_builder.0.text].
Documentation
docs/tools/overview.mdlists the Statamic permission each asset action requires, and thecreate,updateanddeleteasset rows that were missing from or outside its table.
Full Changelog: v3.4.1...v3.5.0