feat(networks): hand a role's non-canonical siblings over to its canonical URL

Some servers build every absolute URL from one site URL, so a second
network cannot be answered under its own origin. reachability.handover
keeps the siblings but turns each one outside the canonical network into a
302 to the same path on the canonical URL (basic and ws_generic vhosts).
The redirect target comes from the canonical domain, not the application
id, because lookup('tls', application_id) follows the network of the vhost
being rendered and would point the sibling at itself.

The flag also drops Onion-Location for the role (Tor Browser would bounce
between the two), skips those siblings in the CSP crawl, expects 302 from
the webserver health check and keeps Playwright on the canonical domain.
The key needs a nocheck reason like single_mode.

Mattermost opts in: it builds every OAuth callback from its one SiteURL, so
an onion login came back on the clearnet callback and failed with 400.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-16 12:37:16 +02:00
1 parent 0fde8c2774
commit 55c95e6960
14 files changed
+143 -27

No files matched your search

@@ -16,6 +16,7 @@ from utils.networks.reachability import (
network,
network_of,
resolve_node_mode,
role_handover,
role_reachability,
sibling_domain,
)
@@ -130,6 +131,14 @@ class TestRoleReachability(unittest.TestCase):
with self.assertRaises(TypeError):
role_reachability(_cfg(single_mode="yes"))
def test_handover_defaults_to_false(self) -> None:
self.assertFalse(role_handover({}))
self.assertTrue(role_handover(_cfg(handover=True)))
def test_handover_must_be_boolean(self) -> None:
with self.assertRaises(TypeError):
role_handover(_cfg(handover="yes"))
def test_tor_disabled_role_loses_tor(self) -> None:
self.assertEqual(allowed_networks({}, tor_enabled=False), ((CLEARNET,), False))