feat(logout): hand the browser on to the conductor of the next network

A node serving several networks runs one universal-logout conductor per network, and a page served over HTTPS cannot fetch the HTTP onion hosts, so one conductor cannot clear the other network's sessions. compose.yml.j2 now gives every conductor the url.origin of the other networks' conductors in LOGOUT_SIBLINGS (empty on a single-network node, which disables the hand-off), and the Keycloak logout panel that frames the conductor follows its handoff report to the next conductor once the sweep is done, accepting only an http or https URL.

The pinned image v1.4.2 ignores LOGOUT_SIBLINGS and never reports handoff, so behaviour changes only with the bump to the universal-logout release that carries the reachability probe. test_compose_siblings.py renders single- and multi-network nodes; logout-panel.test.js covers the handoff branch and rejects non-web URLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-30 21:46:00 +01:00
1 parent d9a65873de
commit e0179a0893
6 files changed
+236 -2

No files matched your search

@@ -16,6 +16,7 @@ const LOCALE = path.join(PROJECT_ROOT, "locale");
const LANGUAGES = path.join(PROJECT_ROOT, "meta/languages.yml");
const ORIGIN = "https://logout.example.test";
const DOMAINS = ["https://shop.example.test", "https://cloud.example.test"];
const SIBLING = `http://logout.${"a".repeat(56)}.onion/?handoff=`;
function readEnglish() {
const out = {};
@@ -126,11 +127,12 @@ function mount({ lang = "en", hostname = "auth.example.test", path: pathname = "
const body = element();
const listeners = {};
const timers = {};
const visited = [];
let next = 0;
global.window = {
__INFINITO_LOGOUT__: { origin: ORIGIN, i18n: readCatalogue() },
location: { pathname, hostname },
location: { pathname, hostname, replace: (url) => visited.push(url) },
addEventListener(type, fn) {
listeners[type] = listeners[type] || [];
if (!listeners[type].includes(fn)) listeners[type].push(fn);
@@ -169,9 +171,13 @@ function mount({ lang = "en", hostname = "auth.example.test", path: pathname = "
(listeners.message || []).forEach((fn) =>
fn({ origin: ORIGIN, data: { source: "universal-logout", ...payload } }),
);
const send = (origin, data) =>
(listeners.message || []).forEach((fn) => fn({ origin, data }));
const panel = () => body.children[0];
return {
post,
send,
visited,
panel,
status: () => panel().children[0].textContent,
hint: () => panel().children[1].textContent,
@@ -261,3 +267,44 @@ test("the panel stays off every other Keycloak page", () => {
const page = mount({ path: "/realms/x/account" });
assert.equal(page.armed(), 0);
});
test("a hand-off moves the whole page to the next network's conductor", () => {
const page = mount();
page.post({ type: "start", domains: DOMAINS });
page.post({ type: "host", host: DOMAINS[0], ok: true });
page.post({ type: "host", host: DOMAINS[1], ok: true });
page.post({ type: "done", total: 2, failed: 0 });
page.post({ type: "handoff", url: SIBLING });
assert.deepEqual(page.visited, [SIBLING]);
});
test("a hand-off is not held back by the unload guard", () => {
const page = mount();
page.post({ type: "start", domains: DOMAINS });
assert.equal(page.armed(), 1);
page.post({ type: "handoff", url: SIBLING });
assert.deepEqual(page.visited, [SIBLING]);
assert.equal(page.armed(), 0, "a guard left armed would stop the navigation with a leave-page prompt");
});
test("only the conductor can hand the page off", () => {
const page = mount();
page.send("https://evil.test", { source: "universal-logout", type: "handoff", url: SIBLING });
page.send(ORIGIN, { type: "handoff", url: SIBLING });
assert.deepEqual(page.visited, []);
});
test("a hand-off to anything but an absolute http(s) URL is ignored", () => {
const page = mount();
page.post({ type: "start", domains: DOMAINS });
for (const url of ["javascript:alert(1)", "data:text/html,x", "/realms/x", "", undefined]) {
page.post({ type: "handoff", url });
}
assert.deepEqual(page.visited, []);
assert.equal(page.armed(), 1, "a refused hand-off leaves the sweep guarded");
});