1ccacad63281094de8a3372d5a507d38f9969e5c
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4d9b798d50 |
web: a LazyCat box's administrators open the page with the box's sign-in (MAGPIE_WEB_SIGN_IN=lazycat) (#5987)
magpie in a LazyCat app (懒猫微服) is opened from the box's app list by someone signed in to the box already, and asks for a key they never saw: it is in the container's log. A package can only hand the key to every browser that reaches the app, or put a proxy in front that adds the key's cookie to what the box signed in. The box's ingress, lzc-ingress, sends a browser that isn't signed in to the box's login page, and puts on every request it passes the app the box account (X-HC-User-ID), its role (X-HC-User-Role, ADMIN or NORMAL) and what sent it (X-HC-Source, client for a browser), in place of what the caller sent. With MAGPIE_WEB_SIGN_IN=lazycat webGuard takes that sign-in besides the key: lazyCatSignIn lets in an ADMIN account sent by a browser, each of the three named once, and tells anyone else the box's reason. The box's sign-in is a cookie of the box's, and the box's apps are one site, so a browser sends it with another app's page's requests too: an earlier build of this change let another app's page on the box include /boot.js and read window.bootPrefs. So it is taken only for what the page itself or the user asked for (boxFetched, the Fetch Metadata: Sec-Fetch-Site same-origin or none, or a GET or HEAD navigation to a document from another page), never for another page's script, frame, fetch or form POST, nor from a browser that sends no Fetch Metadata. It sets no cookie of the page's own, so signing out of the box signs out of the page. The key's link and cookie work as before, /api still answers the page alone (webOwnPage), and the gateway's client routes on the page's port go to the gateway first (onePort), which asks for a gateway key. StartWeb refuses another value, and lazycat where LAZYCAT_APP_DOMAIN, which LazyCat sets in an app's containers, isn't set: all magpie can check, so the setting is the package's word that the box's ingress is the only way to the page's port. magpie web prints the box's address beside the link. Docs: reference.md's new LazyCat section, with a manifest and what must never reach the page's port, and gui-shell.md's Browser mode row. On a box (lzcos 1.6.2+fix.4), a probe app that echoes its request headers: a signed-in browser's request carries X-HC-User-ID, X-HC-User-Role ADMIN and X-HC-Source client, forged ones replaced; not signed in, / goes to the login page and a public path gets none of the three (forged ones taken off, repeated or in lower case too), while X-HC-User-Groups passes on as the caller wrote it, so it is never read; a TCP ingress passes every header as sent. Another app's container reaches the app through the ingress alone (straight to the app's container it times out); the box itself, and a container in its network (network_mode: host, which a manifest may set), reach the port. A test app made from the docs' manifest, running a build of this change on |
||
|
|
b6cf5e3eab |
gui: magpie web keeps its sign-in when another service on the same address fills or clears the host's cookies, and a page opened without it says why and takes the key (#2033, 321sssrt-bit)
A browser keeps cookies per host, not per port. magpie web's sign-in cookie on http://<tailscale-ip>:3430 is the same host's as every other service on that IP's other ports, so one of them could take it away, and a bookmark then answered only "open the link magpie web printed when it started". Reproduced in Docker (linux/arm64, MAGPIE_WEB_KEY fixed, as the reporter runs it) with Chromium and WebKit on the old binary: - docker restart, recreate (an update), browser restart: still signed in (the key, its derivation and the 400-day cookie are fine); - another port on the same host setting ~400 cookies: Chromium evicts the sign-in (401), WebKit keeps it; - another port answering Clear-Site-Data: "cookies" (a sign-out often does): 401 in both; - the page opened by another name for the host (localhost vs IP): 401. Changed: - the sign-in cookie is sent with Priority=High, so Chrome evicts it last when the host's cookies overflow (with it, the flood case stays signed in); - every magpie_web_<port> cookie the browser sends is tried, so a stale one sent first no longer hides the right one; - an HTML page opened without the sign-in gets a page that says which case it is (no cookie sent for this address, or a cookie holding another key) and a field to paste MAGPIE_WEB_KEY into; POST /_magpie/sign-in sets the cookie and goes back to the page asked for (local paths only: no scheme, host, //, /\ or the sign-in itself). The key is never in the page. API calls get a plain 401 that now says the reason too, and the turn-away is logged with it. - docs/reference.md's Docker web section says how long a sign-in lasts and what can take it away. Run: - TestWebGuardBookmark (link cookie has Priority=High; stale cookie first still passes; both reasons; API 401; wrong key 401 with no cookie; right key 303 to /?view=usage with a 400-day cookie; external, //, /\, javascript:, empty, sign-in-path and CRLF back values all go to /). Broken by hand: the old guard fails it (link without Priority), dropping Priority alone fails it, reading only the first cookie fails it (stale cookie: 401). - The Docker matrix above again on the new binary: the flood keeps the sign-in in Chromium; Clear-Site-Data and the other name get the form, and the form signs in (wrong key turned away, right key back to /?view=usage, 200) in Chromium and WebKit; the log says "turned away ... no cookie sent". - go test -tags nogui ./internal/gui (ok, 173s), gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows. Not tried: the reporter's own browser and Tailscale address; which service on their host takes the cookie is not known. |
||
|
|
8f915a5a23 | web: MAGPIE_WEB_KEY takes letters, digits and - . _ ~ only — a cookie can't hold a space, ; or a quote, so the browser was sent a cookie that wasn't the key and turned away with no word why | ||
|
|
84ef25805e | web: MAGPIE_WEB_KEY keeps the page's key across runs — for magpie web kept running as a service, where a new key each start signs every browser out; with it the cookie outlives the browser session too (400 days, Chrome's most). Unset, each run makes its own key in a session cookie, as before. A key under 16 characters is refused. (#109) | ||
|
|
59e4f417b2 | web: magpie web serves the app's window to a browser, with the gateway beside it — for a computer that can't show the app: no desktop, WSL, a server over SSH, or the CLI-only build, which now carries the page too (what of the app needs Wails is left out of nogui builds). Every request needs this run's key, which the printed link carries and trades for a cookie other sites' pages can't send with a POST; --lan serves it on the network too, with a warning, --addr elsewhere, --no-open leaves the browser shut. In the browser the page opens links and sign-ins itself, names a folder instead of opening it, and leaves out the tray, the Dock and open at login. Tested from a nogui build in a sandbox: no key, a wrong key and a cookieless POST are refused; with the link Agents, Providers and Settings load and a setting saves. Issue #102 |