Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions admin/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,38 @@ a.pm-btn-primary:link, a.pm-btn-primary:visited { color: #fff; }
cursor: help;
}

.pm-tag--official {
background: rgba(20,148,116,.12);
color: var(--ep-accent-d);
border: 1px solid rgba(20,148,116,.3);
cursor: help;
}
.pm-tag--third-party {
background: var(--line-2);
color: var(--ink-2);
border: 1px solid var(--line);
cursor: help;
}

/* Third-party install confirmation */
.pm-dialog-content {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 101;
width: min(460px, calc(100vw - 32px));
background: var(--panel);
color: var(--ink);
border: 1px solid var(--line);
border-radius: var(--r-lg);
padding: 20px;
box-shadow: 0 10px 38px -10px rgba(0,0,0,.35);
}
.pm-dialog-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.pm-dialog-body { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.pm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Toolbar (search + sort) */
.pm-toolbar {
display: flex;
Expand Down
76 changes: 72 additions & 4 deletions admin/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {useDebounce} from "../utils/useDebounce.ts";
import {Trans, useTranslation} from "react-i18next";
import {ArrowUpFromDot, Download, ExternalLink, Plug, RefreshCw, Search, Trash, X} from "lucide-react";
import {IconButton} from "../components/IconButton.tsx";
import * as Dialog from "@radix-ui/react-dialog";

export const HomePage = () => {
const pluginsSocket = useStore(state => state.pluginsSocket)
Expand All @@ -24,6 +25,9 @@ export const HomePage = () => {
searchTerm: '',
})
const [searchTerm, setSearchTerm] = useState<string>('')
// Third-party plugin awaiting the admin's confirmation before install.
const [confirmInstall, setConfirmInstall] =
useState<{name: string, version?: string} | null>(null)
const {t} = useTranslation()

const updatableCount = useMemo(
Expand Down Expand Up @@ -140,18 +144,67 @@ export const HomePage = () => {
setInstalledPlugins(installedPlugins.filter(i => i.name !== pluginName))
}

const installPlugin = (pluginName: string) => {
pluginsSocket!.emit('install', pluginName)
// With a version, the server installs exactly that release: the one the
// catalog showed and classified, not whatever is latest by then.
const installPlugin = (pluginName: string, version?: string) => {
pluginsSocket!.emit('install', version ? {name: pluginName, version} : pluginName)
setPlugins(plugins.filter(p => p.name !== pluginName))
}

// Official plugins install with one click. A third-party plugin runs code
// the Etherpad project has not reviewed, so the admin confirms first; the
// extra, deliberate click also blunts clickjacking of the Install button.
// Updates go through here too; an update whose target version could not
// be classified is treated as third-party.
const requestInstall = (plugin: {name: string, version?: string, official?: boolean}) => {
if (plugin.official === true) {
installPlugin(plugin.name, plugin.version)
} else {
setConfirmInstall({name: plugin.name, version: plugin.version})
}
}

useDebounce(() => {
setSearchParams({...searchParams, offset: 0, searchTerm})
}, 500, [searchTerm])

return (
<div className="pm-page">

<Dialog.Root
open={confirmInstall !== null}
onOpenChange={(open) => { if (!open) setConfirmInstall(null) }}
>
<Dialog.Portal>
<Dialog.Overlay className="dialog-confirm-overlay"/>
<Dialog.Content className="pm-dialog-content" data-testid="third-party-confirm">
<Dialog.Title className="pm-dialog-title">
<Trans i18nKey="admin_plugins.third_party_confirm_title"/>
</Dialog.Title>
<Dialog.Description className="pm-dialog-body">
{t('admin_plugins.third_party_confirm_body', {plugin: confirmInstall?.name ?? ''})}
</Dialog.Description>
<div className="pm-dialog-actions">
<Dialog.Close asChild>
<button className="pm-btn pm-btn-ghost" autoFocus>
<Trans i18nKey="admin_pads.cancel"/>
</button>
</Dialog.Close>
<button
className="pm-btn pm-btn-primary"
onClick={() => {
const target = confirmInstall
setConfirmInstall(null)
if (target) installPlugin(target.name, target.version)
}}
>
<Download size={13}/> <Trans i18nKey="admin_plugins.available_install.value"/>
</button>
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>

{catalogDisabled && (
<div className="pm-banner pm-banner-info" role="status">
<Trans i18nKey="admin_plugins.catalog_disabled"/>
Expand Down Expand Up @@ -264,7 +317,11 @@ export const HomePage = () => {
<div className="pm-installed-actions">
{plugin.updatable ? (
<IconButton
onClick={() => installPlugin(plugin.name)}
onClick={() => requestInstall({
name: plugin.name,
version: plugin.latestVersion,
official: plugin.official,
})}
icon={<ArrowUpFromDot size={14}/>}
title={t('admin_plugins.update_tooltip')}
/>
Expand Down Expand Up @@ -362,6 +419,17 @@ export const HomePage = () => {
target="_blank"
rel="noopener noreferrer"
>{plugin.name}</a>
{plugin.official ? (
<span
className="pm-tag pm-tag--official"
title={t('admin_plugins.tag_official_title')}
><Trans i18nKey="admin_plugins.tag_official"/></span>
) : (
<span
className="pm-tag pm-tag--third-party"
title={t('admin_plugins.tag_third_party_title')}
><Trans i18nKey="admin_plugins.tag_third_party"/></span>
)}
</div>
</div>
</td>
Expand All @@ -385,7 +453,7 @@ export const HomePage = () => {
<td className="pm-cell-action">
<button
className="pm-btn pm-btn-primary pm-btn--sm"
onClick={() => installPlugin(plugin.name)}
onClick={() => requestInstall(plugin)}
>
<Download size={13}/> <Trans i18nKey="admin_plugins.available_install.value"/>
</button>
Expand Down
8 changes: 8 additions & 0 deletions admin/src/pages/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export type PluginDef = {
description: string,
version: string,
time: string,
/**
* Published from an ether/* GitHub repository, as shown by npm provenance.
* Computed by the server; anything else is third-party.
*/
official: boolean,
/**
* `@feature:*` Playwright tags for core specs the plugin intentionally
Expand All @@ -20,6 +24,10 @@ export type InstalledPlugin = {
version: string,
description?: string,
updatable?: boolean,
/** For an updatable plugin: the catalog version an update installs. */
latestVersion?: string,
/** For an updatable plugin: whether that version is official. */
official?: boolean,
/**
* Reason this installed plugin should no longer be used (npm deprecation
* message, or core's reason for treating it as superseded). Set by the
Expand Down
37 changes: 37 additions & 0 deletions doc/plugins.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,43 @@ a failed lookup — if the npm registry cannot be reached the full catalog is
listed and installs proceed — and `pnpm run plugins i ep_<name>` on the server
installs it anyway, for an operator who knows what they are doing.

==== Official and third-party plugins

Anyone can publish an `ep_*` package to npm, and the Etherpad project cannot
review all of them. The catalog marks a plugin *Official* when npm
provenance shows that the published version was built by GitHub Actions from
a repository in the https://github.com/ether[ether] GitHub org. Everything
else is labelled *Third-party*: it is not maintained by the Etherpad
project and it runs code on your server. The admin UI asks for confirmation
before installing a third-party plugin; official plugins install with one
click. Updates of an installed plugin follow the same rule, and an install
always fetches the exact version the catalog showed, so a label shown for one
release never covers a different one.

The check is done when the catalog is refreshed and cached per published
version, so it adds no latency to browsing. It relies on npm provenance
rather than on the package's `repository` field, its maintainer list or the
feed's own flags, because a publisher can set any of those to whatever they
like (`src/static/js/pluginfw/pluginTrust.ts`). A plugin from the ether org
that has not been released with provenance yet shows as third-party until its
next release.

Placeholder packages (a `0.0.0-*` version, or no `repository` in
package.json) are left out of the list, but a search for the exact package
name still finds them, so you can find a package you have just published.

The `pluginCatalogThirdParty` setting in `settings.json` changes this:

|===
| Value | Effect

| `label` (default) | List third-party plugins with a badge; placeholders only on an exact-name search.
| `hide` | List official plugins only. Needs registry.npmjs.org: if it cannot be reached, nothing can be verified and the list is empty.
| `all` | List everything, placeholders included.
|===

None of this affects `pnpm run plugins i ep_<name>` on the server.

=== Folder structure

Ideally a plugin has the following folder structure:
Expand Down
35 changes: 35 additions & 0 deletions doc/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@ a failed lookup — if the npm registry cannot be reached the full catalog is
listed and installs proceed — and `pnpm run plugins i ep_<name>` on the server
installs it anyway, for an operator who knows what they are doing.

### Official and third-party plugins

Anyone can publish an `ep_*` package to npm, and the Etherpad project cannot
review all of them. The catalog marks a plugin **Official** when npm
provenance shows that the published version was built by GitHub Actions from
a repository in the [ether](https://github.com/ether) GitHub org. Everything
else is labelled **Third-party**: it is not maintained by the Etherpad
project and it runs code on your server. The admin UI asks for confirmation
before installing a third-party plugin; official plugins install with one
click. Updates of an installed plugin follow the same rule, and an install
always fetches the exact version the catalog showed, so a label shown for one
release never covers a different one.

The check is done when the catalog is refreshed and cached per published
version, so it adds no latency to browsing. It relies on npm provenance
rather than on the package's `repository` field, its maintainer list or the
feed's own flags, because a publisher can set any of those to whatever they
like (`src/static/js/pluginfw/pluginTrust.ts`). A plugin from the ether org
that has not been released with provenance yet shows as third-party until its
next release.

Placeholder packages — a `0.0.0-*` version, or no `repository` in
package.json — are left out of the list, but a search for the exact package
name still finds them, so you can find a package you have just published.

The `pluginCatalogThirdParty` setting in `settings.json` changes this:

| Value | Effect |
| --- | --- |
| `label` (default) | List third-party plugins with a badge; placeholders only on an exact-name search. |
| `hide` | List official plugins only. Needs registry.npmjs.org: if it cannot be reached, nothing can be verified and the list is empty. |
| `all` | List everything, placeholders included. |

None of this affects `pnpm run plugins i ep_<name>` on the server.

## Folder structure

Ideally a plugin has the following folder structure:
Expand Down
17 changes: 17 additions & 0 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,23 @@
"pluginCatalog": "${PRIVACY_PLUGIN_CATALOG:true}"
},

/*
* Plugins in the admin catalog that are not published by the Etherpad
* project are labelled "Third-party": they are not reviewed by the project
* and run code on your server. "Official" means npm provenance shows the
* package was built from a repository in the ether GitHub org.
* - "label" (default): list third-party plugins with a badge and ask for
* confirmation before installing them. Placeholder
* packages (0.0.0-* versions, no repository) are only
* listed when searched for by their exact name.
* - "hide" : list official plugins only. Official status needs
* registry.npmjs.org; if it cannot be reached, nothing
* can be verified and the list is empty.
* - "all" : list everything, placeholders included.
* `pnpm run plugins i ep_<name>` on the server is never affected.
*/
"pluginCatalogThirdParty": "${PLUGIN_CATALOG_THIRD_PARTY:label}",

/*
* Should we suppress errors from being visible in the default Pad Text?
*/
Expand Down
6 changes: 6 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
"admin_plugins.deprecated_title": "This plugin is no longer maintained and may break Etherpad. Consider uninstalling it.",
"admin_plugins.tag_core": "Core",
"admin_plugins.tag_deprecated": "Deprecated",
"admin_plugins.tag_official": "Official",
"admin_plugins.tag_official_title": "Published by the Etherpad project from the ether GitHub organization.",
"admin_plugins.tag_third_party": "Third-party",
"admin_plugins.tag_third_party_title": "Not maintained by the Etherpad project. Plugins run code on your server.",
"admin_plugins.third_party_confirm_title": "Install a third-party plugin?",
"admin_plugins.third_party_confirm_body": "{{plugin}} is not maintained by the Etherpad project and has not been reviewed by it. Plugins run code on your server, with access to your pads and settings. Only install it if you trust its author.",
"admin_plugins.update_tooltip": "Update",
"admin_plugins.updates_available": "Updates available",
"admin_plugins.update_now": "Update",
Expand Down
Loading
Loading