Create the server token at install and document the security boundary

This commit is contained in:
2026-11-10 00:59:39 +00:00
parent 547d4d9822
commit 12a74247ae
7 changed files with 245 additions and 1 deletions
+18
View File
@@ -257,6 +257,24 @@ class SetupNativeTests(unittest.TestCase):
self.assertTrue((prefix / "lib/web/src/proxySecurity.js").is_file())
self.assertEqual(web["port"], 8082)
def test_server_token_is_created_private_once_beside_the_web_auth(self):
with tempfile.TemporaryDirectory() as directory:
installer = self.installer(directory, Recorder())
prefix = Path(directory) / "prefix"
installer.prepare_layout(prefix)
with patch.object(setup_native.shutil, "which", side_effect=self.which_all()):
web = installer.configure_web(prefix, setup_native.arguments([]))
token = Path(web["server_token_file"])
before = token.read_bytes()
installer.configure_web(prefix, setup_native.arguments([]))
self.assertEqual(token.parent, Path(web["auth_file"]).parent)
self.assertEqual(token.read_bytes(), before)
self.assertEqual(token.stat().st_mode & 0o777, 0o600)
self.assertGreaterEqual(len(before.strip()), 32)
token.chmod(0o644)
with self.assertRaises(ValueError):
installer.ensure_server_token(token)
def test_new_web_password_must_be_chosen(self):
with tempfile.TemporaryDirectory() as directory:
installer = self.installer(directory, Recorder())