permissions: a plugin can mark part of its surface owner-only
A plugin worth granting to a Member can also hold the credential the rest of it runs on. Jellyfin's /_config stores a server's admin token and drives account provisioning; the rest of the plugin is exactly what a Member should have. The choice was all of it or none of it. `ownerOnly` on a plugin permission takes sub-paths relative to the mount prefix. The permission stays fully grantable — this is not the ownerOnly PERMISSION that manifest.ts refuses, and that refusal still stands: a permission nobody can delegate is a contradiction. This says a few paths administer the plugin rather than use it. Declared by the plugin, enforced by the platform. A plugin could check this itself and the first one would; the tenth would add a route and forget, with no boot failure and no warning — the shape assertPermissionTotality exists to prevent. In the gate it is enforced once, on the door they all pass through, and a route added later by someone who never read the manifest is covered by default. Checked before selfService and before kind. A path that is somehow both self-service and owner-only is a contradiction, and the safe reading has to win. A write grant does not unlock it either — level is not the question this answers. Also forwards X-Officer-Owner and X-Officer-Level to a sidecar whose proxy names its permission key, for the finer decisions the platform cannot make for it: whose rows a read returns, which fields a level may see. Facts, never the role name — a plugin branching on "Super Admin" would give every plugin repository an opinion about the platform's role vocabulary, and renaming a role would change authorization in code the platform does not own. These are safe to trust only because the proxy copies a three-item allowlist off the inbound request; that is now written where it would be changed. The owner's level is reported as write rather than the absent 'none': they hold everything implicitly and appear in no grants map, so the raw lookup inverts the meaning for the one account that can do anything. No plugin declares one yet. Jellyfin cannot until connections stop being per-user — locking /_config today leaves a Member with a plugin that only shows a connect form they may not submit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,26 @@ export type PluginPermission = {
|
||||
* broken feature where a withheld permission should be.
|
||||
*/
|
||||
readOnlyWrites?: string[];
|
||||
/**
|
||||
* Sub-paths, relative to the plugin's mount prefix, that ONLY the owner may reach — at any granted
|
||||
* level, by any method.
|
||||
*
|
||||
* For the administrative corner of a surface that is otherwise worth sharing. Jellyfin's `/_config`
|
||||
* stores a server's admin token and drives account provisioning; the rest of the plugin is exactly what
|
||||
* a Member should have. Without this the choice was the whole plugin or none of it.
|
||||
*
|
||||
* Note what this is NOT. It does not make the PERMISSION owner-only — see the comment above, which
|
||||
* still stands: a permission nobody can delegate is a contradiction. The permission stays fully
|
||||
* grantable and these few paths are marked as administering the plugin rather than using it.
|
||||
*
|
||||
* DECLARED here, ENFORCED by the platform's permission gate. The plugin knows which of its paths are
|
||||
* settings; the platform is the thing that cannot forget to check. A plugin doing this itself would
|
||||
* work until the tenth one added a route and did not, with no boot failure and no warning — the shape
|
||||
* `assertPermissionTotality` exists to prevent.
|
||||
*
|
||||
* Prefix-matched: `/_config` covers `/_config/3/users`.
|
||||
*/
|
||||
ownerOnly?: string[];
|
||||
};
|
||||
|
||||
/** The package managers the platform knows how to drive. Mirrors `PM` in machine-setup's lib/base.sh. */
|
||||
@@ -542,6 +562,15 @@ export function manifestProblems(appName: string, manifest: Partial<PluginManife
|
||||
if (typeof permission.label !== 'string' || !permission.label) {
|
||||
problems.push(`permissions[${i}].label is required`);
|
||||
}
|
||||
// A leading slash is not cosmetic: these are matched against the path left after the plugin's own
|
||||
// prefix is stripped, which always starts with one. `_config` would match nothing and would do it
|
||||
// silently — an owner-only route that is quietly reachable by everyone is the worst possible way to
|
||||
// get this wrong, so it is a manifest error rather than a surprise.
|
||||
for (const [j, sub] of (permission.ownerOnly ?? []).entries()) {
|
||||
if (typeof sub !== 'string' || !sub.startsWith('/')) {
|
||||
problems.push(`permissions[${i}].ownerOnly[${j}] must be a path starting with "/"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
problems.push(...osDependencyProblems(manifest.osDependencies));
|
||||
|
||||
@@ -139,6 +139,10 @@ function pluginPermissions(state: PluginState): Permission[] {
|
||||
api: index === 0 ? [prefix] : [],
|
||||
routes: index === 0 ? [prefix] : [],
|
||||
...(permission.readOnlyWrites ? { readOnlyWrites: permission.readOnlyWrites } : {}),
|
||||
// Only meaningful on the entry that claims the paths — a later permission claims no `api`, so an
|
||||
// `ownerOnly` on it would match nothing. Threaded anyway rather than dropped: silently ignoring a
|
||||
// declaration is how a plugin author concludes the field does not work.
|
||||
...(permission.ownerOnly ? { ownerOnly: permission.ownerOnly } : {}),
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user