Replies: 1 comment
|
Follow-up with three things I did not have when I opened this: how often the same gap has been asked for, a workaround that actually covers the command palette, and the exact set of files a patch has to touch (it is larger than it looks). This is a repeated request, not a one-offFour open Ideas threads describe the same missing capability, the oldest from five months ago, none with a maintainer reply:
I searched all 443 discussions including the Roadmap category. The two Roadmap items about the sidebar (#1763, #1764) are about grouping and hiding collections by site config, not by the signed-in user's role. Correction to my own workaround listI wrote that hiding the item from an integration is fragile and leaves the command palette listing it. That is true for CSS, but there is a better workaround, and it works: filter the manifest on the server. Both the sidebar and the command palette build plugin items from Measured on 0.37.0 by demoting the dev user in the local D1 and restoring it: role 40 receives I mention it because it is evidence for the design, not against it: the manifest is already the single source both surfaces read, so The patch is 8 files, and one of them is a trapReading
Happy to send the PR with tests, including one that demotes a user and asserts the sandboxed path keeps the field (point 3). Per CONTRIBUTING I am waiting for maintainer approval before opening it. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
A plugin admin page is visible in the sidebar for every signed-in role, but the route behind it is gated by role. When they disagree, the Editor clicks a menu item and gets a red "Plugin Error / Plugin responded with 403" page.
Where it is (0.37.0 and
main):packages/core/src/plugins/types.ts:1266:PluginAdminPageis{ path, label, icon? }. No role, no permission.packages/admin/src/components/Sidebar.tsx: every core item carriesminRole(CommentsandMenusareROLE_EDITOR,UsersandPluginsareROLE_ADMIN) and the four groups go throughfilterNavItemsByRole(). The plugin loop pushes{ to, label, icon }withoutminRole, sofilterNavItemsByRole(pluginItems, userRole)is a no-op for plugin pages.packages/core/src/astro/routes/api/plugins/[pluginId]/[...path].ts:53: a route withoutpermissionrequiresplugins:manage, which is Admin.So the default for a plugin author is: page shown to everyone, route closed to everyone below Admin. The Editor sees the item and cannot open it.
Two real cases on our sites:
plugins:manage, so the Editor sees "Forms" and "Submissions" and gets "Failed to load forms" / "No forms yet" (plugin-forms: all routes default toplugins:manage, so an Editor gets 403 and the admin shows "No forms yet" instead of a permission error #3033).Current workarounds are all bad: drop
admin.pages(page gone for the Admin too), open the route withpermission: "plugins:read"(page works, but then it is open to a role it was not meant for), or hide the item with CSS from an integration (fragile, and the command palette still lists it).Proposal
Let the page declare who should see it, and have the sidebar and command palette apply the same filter they already apply to core items:
Sidebar.tsx: map the string to the numeric role and setminRoleon the plugin nav item;filterNavItemsByRoledoes the rest.admin.pages, passed through_buildManifest().minRoleonly decides visibility; thepermissionon the route keeps deciding access, so a hand-typed URL still gets the 403.Backward compatible: without
minRolenothing changes.An alternative that needs no new field: derive visibility from the route. If a page in
blocksmode calls a route whose effective permission the user does not hold, skip the item. It is cheaper for authors but couples the nav to route metadata, and a page can call more than one route, so the explicit field looks simpler to reason about.Related: #866 and #1023 are about hiding core items; this one is the same gap on the plugin side.
All reactions