Use isolated native Windows browser for attended WSL login
All checks were successful
CCR intake gate / gate (push) Successful in 2m15s
CI Smoke / host-smoke (push) Successful in 1s
CI Smoke / container-smoke (push) Successful in 3s

Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a1abf1-7e95-7141-87c9-ee78332bf790
This commit is contained in:
codex 2026-11-06 19:53:07 +01:00
parent de06f49037
commit 8519459e6f
4 changed files with 285 additions and 3 deletions

View file

@ -1,12 +1,15 @@
#!/usr/bin/env python3
"""Open the approved OpenBao login in a new empty Playwright Chromium profile.
"""Open approved OpenBao login in a new isolated operator browser profile.
The Windows default browser is not used. A previous login opened Firefox,
which was already signed in as another account. This launcher uses the
headed Chromium binary pinned by coulomb-social's Playwright install.
native Windows Edge in a private disposable profile on WSL, where the Linux
window/input path proved unreliable. Other Linux hosts retain pinned Chromium.
"""
import importlib.util
import json
import os
import platform
import pwd
import subprocess
import sys
@ -14,7 +17,6 @@ import tempfile
from pathlib import Path
from urllib.parse import parse_qs, urlsplit
BROWSERS_JSON = Path(
"/home/worsch/coulomb-social/scripts/node_modules/playwright-core/browsers.json"
)
@ -118,6 +120,20 @@ def stamp(result):
def open_url(url):
if not allowed(url):
stamp("rejected")
return 1
if "microsoft" in platform.release().lower():
path = Path(__file__).resolve().with_name("windows_browser.py")
try:
spec = importlib.util.spec_from_file_location("operator_windows_browser", path)
native = importlib.util.module_from_spec(spec)
spec.loader.exec_module(native)
opened = native.launch(url)
except Exception: # noqa: BLE001 — keep native browser setup details contained
opened = False
stamp("opened" if opened else "windows-open-failed")
return 0 if opened else 1
if not os.environ.get("DISPLAY") and not os.environ.get("WAYLAND_DISPLAY"):
stamp("no-display")
return 1