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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Notable fixes

- **Updates — pads no longer call `/api/version-status` when `updates.tier` is `"off"` (#8573).** The server does not register that endpoint when the tier is off, but the pad still requested it on every load, leaving a 404 in the browser's network tab. The server now sends `clientVars.updateCheck: false` and the pad skips the request. Other tiers are unchanged. Reported by @n-goncalves.
- **Admin UI — no more `/admin/update/status` request when `updates.tier` is `"off"` (#8573).** The server does not register that route when the tier is off, but the admin banner and update page still requested it. The admin UI now reads the tier from its settings socket and skips the request. Instead it shows a notice that update notifications are turned off, so you may not hear about security updates, with how to turn them back on (`updates.tier` in `settings.json` or the `UPDATES_TIER` environment variable) and a link to the update docs. The notice can be dismissed for the browser session. The troubleshooting page also stops showing "Update available: undefined" when `privacy.updateCheck` is `false`. Other tiers are unchanged.

# 3.3.22

Expand Down
9 changes: 9 additions & 0 deletions admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export const App = () => {
if (settings && typeof settings.flags === 'object' && settings.flags) {
useStore.getState().setGdprAuthorErasureEnabled(
!!settings.flags.gdprAuthorErasure);
if (typeof settings.flags.updatesTier === 'string') {
useStore.getState().setUpdatesTier(settings.flags.updatesTier);
}
}
if (settings.results === 'NOT_ALLOWED') {
console.log('Not allowed to view settings.json')
Expand All @@ -92,6 +95,12 @@ export const App = () => {
useStore.getState().setShowLoading(false);
});

// Sent by the server on every connect, even when settings.json can't be
// read. The update banner and page wait for it (issue #8573).
settingSocket.on('updatesTier', (tier: unknown) => {
if (typeof tier === 'string') useStore.getState().setUpdatesTier(tier);
});

settingSocket.on('saveprogress', (status: string, payload?: {message?: string}) => {
const {setToastState} = useStore.getState();
if (status === 'saved') {
Expand Down
29 changes: 27 additions & 2 deletions admin/src/components/UpdateBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {useEffect, useState} from 'react';
import {Link} from 'react-router-dom';
import {Link, useLocation} from 'react-router-dom';
import {Trans, useTranslation} from 'react-i18next';
import {useStore} from '../store/store';
import {UpdatesOffNotice} from './UpdatesOffNotice';

// Dismissal lasts for the browser session only, so an admin who turned
// updates off is reminded again next time they sign in.
const OFF_DISMISS_KEY = 'etherpad.admin.updatesOffNoticeDismissed';
const readDismissed = (): boolean => {
try { return window.sessionStorage.getItem(OFF_DISMISS_KEY) === '1'; } catch { return false; }
};

const fmtRemaining = (ms: number): string => {
if (ms <= 0) return '0s';
Expand All @@ -15,15 +23,22 @@ export const UpdateBanner = () => {
const {t} = useTranslation();
const updateStatus = useStore((s) => s.updateStatus);
const setUpdateStatus = useStore((s) => s.setUpdateStatus);
const updatesTier = useStore((s) => s.updatesTier);
const [offDismissed, setOffDismissed] = useState<boolean>(readDismissed);
// The update page renders the same notice itself; don't show it twice.
const onUpdatePage = useLocation().pathname.replace(/\/+$/, '').endsWith('/update');

useEffect(() => {
// Wait for the tier from the /settings socket. With tier "off" the
// server does not register the status route, so do not request it.
if (updatesTier == null || updatesTier === 'off') return;
let cancelled = false;
fetch('/admin/update/status', {credentials: 'same-origin'})
.then((r) => r.ok ? r.json() : null)
.then((data) => { if (data && !cancelled) setUpdateStatus(data); })
.catch(() => {});
return () => { cancelled = true; };
}, [setUpdateStatus]);
}, [setUpdateStatus, updatesTier]);

const scheduledFor = updateStatus?.execution?.status === 'scheduled'
? (updateStatus.execution as {scheduledFor: string}).scheduledFor
Expand All @@ -38,6 +53,16 @@ export const UpdateBanner = () => {
return () => clearInterval(id);
}, [scheduledFor]);

if (updatesTier === 'off') {
if (offDismissed || onUpdatePage) return null;
return (
<UpdatesOffNotice onDismiss={() => {
try { window.sessionStorage.setItem(OFF_DISMISS_KEY, '1'); } catch {/* noop */}
setOffDismissed(true);
}}/>
);
}

if (!updateStatus) return null;

// Terminal rollback-failed wins over the regular "update available" banner —
Expand Down
37 changes: 37 additions & 0 deletions admin/src/components/UpdatesOffNotice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Trans, useTranslation} from 'react-i18next';

// Shown instead of the update banner / update page when updates.tier is
// "off" (issue #8573). The server does not register /admin/update/status in
// that case, so the UI must not request it; instead it explains the setting
// and how to turn update notifications back on.
//
// The URL is assembled at runtime on purpose: behind a reverse proxy the
// server rewrites every literal "/admin" in the admin bundle to
// "<proxy>/admin", which would corrupt an external docs link.
export const UPDATES_DOCS_URL = new URL('admin/updates.html', 'https://docs.etherpad.org/').href;

export const UpdatesOffNotice = ({onDismiss}: {onDismiss?: () => void}) => {
const {t} = useTranslation();
return (
<div className="update-banner update-banner-off" role="status" data-testid="updates-off-notice">
<div className="update-banner-off-text">
<strong>{t('update.page.disabled')}</strong>{' '}
<span>{t('update.off.body')}</span>{' '}
<span>
<Trans
i18nKey="update.off.howto"
components={{code: <code/>}}
/>
</span>{' '}
<a href={UPDATES_DOCS_URL} rel="noreferrer noopener" target="_blank">
{t('update.off.docs')}
</a>
</div>
{onDismiss && (
<button type="button" className="update-banner-dismiss" onClick={onDismiss}>
{t('update.off.dismiss')}
</button>
)}
</div>
);
};
27 changes: 27 additions & 0 deletions admin/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,33 @@ input, button, select, optgroup, textarea {
font-weight: 500;
}

/* updates.tier "off": informational, not a warning colour (#8573). */
.update-banner-off {
align-items: flex-start;
justify-content: space-between;
background: #eef6fc;
color: #1f3a52;
border-color: #b9d8f0;
border-left: 4px solid #0ea5e9;
line-height: 1.5;
}
.update-banner-off code {
font-size: 13px;
padding: 0 3px;
background: rgba(14, 165, 233, .12);
border-radius: 3px;
}
.update-banner-dismiss {
flex: none;
background: transparent;
border: 1px solid currentColor;
border-radius: 4px;
color: inherit;
font-size: 13px;
padding: 2px 8px;
cursor: pointer;
}

/* Update page layout. */
.update-page { padding: 16px 0; }
.update-page h1 { margin-bottom: 16px; }
Expand Down
29 changes: 20 additions & 9 deletions admin/src/pages/HelpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ export const HelpPage = () => {

const totalBindings = hooks.reduce((n, h) => n + h.parts.length, 0)

const updateAvailable = helpData
? helpData.epVersion.localeCompare(helpData.latestVersion, undefined, {numeric: true}) < 0
// latestVersion is missing when privacy.updateCheck is false (or the
// legacy check has not finished); don't report "update available: undefined".
const latestKnown = !!helpData?.latestVersion
const versionCheckOff = helpData?.versionCheck === false
const updateAvailable = helpData && latestKnown
? helpData.epVersion.localeCompare(helpData.latestVersion!, undefined, {numeric: true}) < 0
: false

const copyDiag = () => {
Expand Down Expand Up @@ -89,17 +93,24 @@ export const HelpPage = () => {
<div className="pm-hv-main">
<div className="pm-hv-lbl"><Trans i18nKey="admin_plugins_info.version"/></div>
<div className="pm-hv-num">{helpData.epVersion}</div>
<div className={`pm-hv-status${updateAvailable ? ' is-warn' : ' is-ok'}`}>
<span className="pm-hv-dot"/>
{updateAvailable
? t('admin_plugins_info.update_available', {version: helpData.latestVersion})
: t('admin_plugins_info.up_to_date')}
</div>
{versionCheckOff ? (
<div className="pm-hv-status is-warn" data-testid="version-check-off">
<span className="pm-hv-dot"/>
<Trans i18nKey="admin_plugins_info.version_check_off" components={{code: <code/>}}/>
</div>
) : latestKnown && (
<div className={`pm-hv-status${updateAvailable ? ' is-warn' : ' is-ok'}`}>
<span className="pm-hv-dot"/>
{updateAvailable
? t('admin_plugins_info.update_available', {version: helpData.latestVersion})
: t('admin_plugins_info.up_to_date')}
</div>
)}
</div>
<div className="pm-hv-meta">
<div className="pm-hv-cell">
<div className="pm-hv-cell-lbl"><Trans i18nKey="admin_plugins_info.version_latest"/></div>
<div className="pm-hv-cell-val">{helpData.latestVersion}</div>
<div className="pm-hv-cell-val">{helpData.latestVersion ?? '—'}</div>
</div>
<div className="pm-hv-cell">
<div className="pm-hv-cell-lbl"><Trans i18nKey="admin_plugins_info.git_sha"/></div>
Expand Down
5 changes: 4 additions & 1 deletion admin/src/pages/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ export type HelpObj = {
installedParts: string[],
installedPlugins: string[],
installedServerHooks: Record<string, never>,
latestVersion: string
// Missing when privacy.updateCheck is false or the check has not finished.
latestVersion?: string,
// False when privacy.updateCheck is false (the latest version is never fetched).
versionCheck?: boolean,
}
36 changes: 28 additions & 8 deletions admin/src/pages/UpdatePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useEffect, useState} from 'react';
import {useEffect, useRef, useState} from 'react';
import {Trans, useTranslation} from 'react-i18next';
import {useStore} from '../store/store';
import {UpdatesOffNotice} from '../components/UpdatesOffNotice';

type FetchState =
| {kind: 'loading'}
Expand All @@ -25,17 +26,27 @@ export const UpdatePage = () => {
const setUpdateStatus = useStore((s) => s.setUpdateStatus);
const log = useStore((s) => s.updateLog);
const setLog = useStore((s) => s.setUpdateLog);
const updatesTier = useStore((s) => s.updatesTier);
// Read inside async callbacks so a request that was started before the
// tier turned "off" can't overwrite the notice or keep polling.
const tierRef = useRef(updatesTier);
tierRef.current = updatesTier;
const tierOff = () => tierRef.current === 'off';
// Self-fetch so the page renders an explicit state even if UpdateBanner's
// best-effort fetch never landed (route returns 404 when tier=off, 401/403
// if requireAdminForStatus is set, or a transient network error).
// best-effort fetch never landed (401/403 if requireAdminForStatus is set,
// or a transient network error). Tier "off" never reaches the fetch: the
// tier comes from the /settings socket (issue #8573).
const [fetchState, setFetchState] = useState<FetchState>(us ? {kind: 'ok'} : {kind: 'loading'});
const [actionInFlight, setActionInFlight] = useState(false);

const refreshStatus = async () => {
if (tierOff()) return;
try {
const r = await fetch('/admin/update/status', {credentials: 'same-origin'});
if (tierOff()) return;
if (r.ok) {
const data = await r.json();
if (tierOff()) return;
setUpdateStatus(data);
setFetchState({kind: 'ok'});
} else if (r.status === 404) {
Expand All @@ -46,25 +57,34 @@ export const UpdatePage = () => {
setFetchState({kind: 'error', status: r.status});
}
} catch {
if (tierOff()) return;
setFetchState({kind: 'error', status: 0});
}
};

useEffect(() => {
// The tier comes from the /settings socket. Until it arrives, keep
// loading. With tier "off" the status route is not registered, so show
// the notice without requesting it (issue #8573).
if (updatesTier == null) return;
if (updatesTier === 'off') {
setFetchState({kind: 'disabled'});
return;
}
let cancelled = false;
void refreshStatus().then(() => { if (cancelled) return; });
return () => { cancelled = true; };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [updatesTier]);

// Poll log + status while the executor is in flight, then stop.
const status = us?.execution?.status ?? 'idle';
const inFlight = IN_FLIGHT_STATUSES.includes(status);
useEffect(() => {
if (!inFlight) return;
if (!inFlight || updatesTier === 'off') return;
let cancelled = false;
const tick = async () => {
if (cancelled) return;
if (cancelled || tierOff()) return;
try {
const lr = await fetch('/admin/update/log', {credentials: 'same-origin'});
if (lr.ok) setLog(await lr.text());
Expand All @@ -75,7 +95,7 @@ export const UpdatePage = () => {
void tick();
return () => { cancelled = true; };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [inFlight]);
}, [inFlight, updatesTier]);

const post = async (path: string) => {
setActionInFlight(true);
Expand Down Expand Up @@ -114,7 +134,7 @@ export const UpdatePage = () => {
return (
<div className="update-page">
<h1><Trans i18nKey="update.page.title"/></h1>
<p>{t('update.page.disabled', {defaultValue: 'Update checks are disabled (updates.tier = "off").'})}</p>
<UpdatesOffNotice/>
</div>
);
}
Expand Down
7 changes: 7 additions & 0 deletions admin/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ type StoreState = {
setAuthors: (authors: AuthorSearchResult)=>void,
gdprAuthorErasureEnabled: boolean,
setGdprAuthorErasureEnabled: (enabled: boolean)=>void,
// updates.tier as reported by the /settings socket. null until the first
// `settings` payload arrives; the update UI waits for it so it never
// requests /admin/update/status when the tier is "off".
updatesTier: string | null,
setUpdatesTier: (tier: string | null) => void,
}


Expand Down Expand Up @@ -125,6 +130,8 @@ export const useStore = create<StoreState>()((set) => ({
setAuthors: (authors)=>set({authors}),
gdprAuthorErasureEnabled: false,
setGdprAuthorErasureEnabled: (gdprAuthorErasureEnabled)=>set({gdprAuthorErasureEnabled}),
updatesTier: null,
setUpdatesTier: (updatesTier) => set({updatesTier}),
}));

export const useResolvedAt = (path: JSONPath): unknown =>
Expand Down
2 changes: 2 additions & 0 deletions doc/admin/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ The notice auto-fades after 8 seconds and can be dismissed immediately. The publ

Set `updates.tier` to `"off"`. The self-updater goes silent — no request to the GitHub Releases API leaves the instance and no banner or badge renders. `GET /api/version-status` is not registered, and the pad client does not request it either: the server sends `clientVars.updateCheck: false`, so the browser's network tab shows no version-status call. Note this does **not** cover the separate legacy version check in `UpdateCheck.ts`, which still fetches `${updateServer}/info.json` until you also set `privacy.updateCheck` to `false` (see [PRIVACY.md](https://github.com/ether/etherpad/blob/develop/PRIVACY.md)).

With the tier off, the admin UI does not request `/admin/update/status` either. It learns the tier from its admin settings socket and shows a notice instead: update notifications are turned off, so you may not hear about security updates. The notice names the setting to change (`updates.tier` in `settings.json`, or the `UPDATES_TIER` environment variable) and links to this page. Admins can dismiss it for the rest of the browser session. To turn update notifications back on, set `updates.tier` to `"notify"` (or a higher tier) and restart Etherpad. If `privacy.updateCheck` is `false`, the admin troubleshooting page says the latest-version check is off instead of showing a latest version.

On Docker / air-gapped installs you can do both without editing `settings.json` inside the image by setting `UPDATES_TIER=off` **and** `PRIVACY_UPDATE_CHECK=false` (add `PRIVACY_PLUGIN_CATALOG=false` to also disable the admin plugin browser's catalogue fetch). See the [Updates & privacy](../docker.md#updates--privacy-offline--air-gapped) table in the Docker docs for the full set of environment variables.

## Privacy
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"admin_plugins_info.tab_server": "Server",
"admin_plugins_info.up_to_date": "Up to date",
"admin_plugins_info.update_available": "Update available: {{version}}",
"admin_plugins_info.version_check_off": "Latest-version check is off (<code>privacy.updateCheck</code> is false)",
"admin_plugins_info.version": "Etherpad version",
"admin_plugins_info.version_latest": "Latest available version",
"admin_plugins_info.version_number": "Version number",
Expand Down Expand Up @@ -178,6 +179,10 @@
"update.page.changelog": "Changelog",
"update.page.up_to_date": "You are running the latest version.",
"update.page.disabled": "Update checks are disabled (updates.tier = \"off\").",
"update.off.body": "This admin panel will not tell you about new Etherpad releases, so you may not hear about security updates.",
"update.off.howto": "To turn update notifications back on, set <code>updates.tier</code> to <code>\"notify\"</code> in settings.json (or set the <code>UPDATES_TIER</code> environment variable) and restart Etherpad.",
"update.off.docs": "Read the update documentation",
"update.off.dismiss": "Dismiss",
"update.page.unauthorized": "You are not authorised to view update status.",
"update.page.error": "Could not load update status (status {{status}}).",
"update.badge.severe": "Etherpad on this server is severely outdated. Tell your admin.",
Expand Down
13 changes: 13 additions & 0 deletions src/node/hooks/express/adminsettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ exports.socketio = (hookName: string, {io}: any) => {
return;
}

// Sent on connect, independent of `load`: `load` emits nothing when the
// settings file can't be read (e.g. running on defaults without
// settings.json), and the update UI waits for the tier before it does
// anything (issue #8573).
socket.emit('updatesTier', settings.updates.tier);

socket.on('load', async (query: string): Promise<any> => {
let data;
try {
Expand All @@ -91,6 +97,10 @@ exports.socketio = (hookName: string, {io}: any) => {
const flags = {
gdprAuthorErasure: !!(settings.gdprAuthorErasure &&
settings.gdprAuthorErasure.enabled),
// The admin UI reads the tier from here instead of probing
// /admin/update/status, which is not registered when the tier is
// "off" (issue #8573). Sent only to admin sockets.
updatesTier: settings.updates.tier,
};
if (settings.showSettingsInAdminPage === false) {
socket.emit('settings', {results: 'NOT_ALLOWED', flags});
Expand Down Expand Up @@ -161,6 +171,9 @@ exports.socketio = (hookName: string, {io}: any) => {
installedServerHooks: mapToObject(hooks),
installedClientHooks: mapToObject(clientHooks),
latestVersion: getLatestVersion(),
// False when privacy.updateCheck is off: latestVersion is then never
// known, so the help page must not claim the install is up to date.
versionCheck: settings.privacy.updateCheck !== false,
})
});

Expand Down
Loading
Loading