Skip to content

fix: sign in through actions instead of exporting tailscale web - #26

Merged
MattDHill merged 3 commits into
masterfrom
fix/sign-in-actions
Nov 20, 2026
Merged

MattDHill merged 3 commits into
masterfrom
fix/sign-in-actions

Conversation

@MattDHill

Copy link
Copy Markdown
Member

What changed and why

The package ran tailscale web --listen 0.0.0.0:8240 and exported it as the Tailscale Admin UI interface. On generic Linux, Tailscale's web client applies no login of its own, and its login API can sign the node in to an arbitrary tailnet or control server, or re-authenticate it. So anyone who could reach that interface could take over the node. Upstream's default listen address is localhost-only, and Tailscale fully supports headless sign-in, so this PR stops running the web client and moves sign-in to owner-only StartOS actions.

  • Web client removed. The web daemon and its health check are gone, setupInterfaces exports nothing, and the web host is retired in the 1.104.7:1 migration (sdk.MultiHost.of(effects, 'web').retire()), per the guide's "Retiring a Host or Binding".
  • New actions. Each runs the tailscale CLI in a temporary subcontainer that mounts the main volume and talks to the running tailscaled over its socket. All of them need the service running.
    • Sign In: tailscale up --reset --json --timeout=60s [--login-server=<url>]. The CLI runs in the background and is stopped once it prints the AuthURL (or a NeedsMachineAuth state). The URL comes back as a copyable, QR and launchable result; if none was printed, it falls back to tailscale status's pending AuthURL. It adds --force-reauth when the node still holds a key (expired or previously signed in). It refuses if the node is already Running.
    • Sign In with Auth Key: the same, with --auth-key=file:/tmp/auth-key. The input is masked, and the key is written into the temp container and never put on the command line.
    • Both take an optional Login Server (http(s):// URL) for Headscale or another self-hosted control server.
    • Node Status: tailscale status --json --peers=false. It shows state, tailnet, device name, MagicDNS name, Tailscale IPs, a pending sign-in link, and health warnings.
    • Log Out: tailscale logout, then it rewrites ts-status.json in place and restarts the service, so serves are re-applied after the next sign-in. It warns before it runs.
  • Task. An important task points to Sign In whenever ts-status.json doesn't record Running: a fresh install, an existing install that was never signed in, or after Log Out. It is cleared once the file records Running.
  • --reset is deliberate. Without it, tailscale up refuses with "requires mentioning all non-default flags" on any node carrying earlier non-default prefs, such as a different ControlURL or an exit node set through the old web UI.
  • What the web UI did that no action does: advertising subnet routes or an exit node, using an exit node, and toggling Tailscale SSH. No action sets these, and it is documented. They are all tailscale set flags, but the README already describes this userspace-networking node as neither a subnet router nor an exit node, and Tailscale SSH would hand out a shell in the container, so I left them out. Prefs already set stay until the next Sign In resets them.
  • SDK bumped from 3.1.1 to 4.1.0. It is mechanical: no code changes, and the lockfile settles after a second npm install. Release notes open with "Requires StartOS 0.4.2 or later." in every locale.
  • README, instructions, the manifest long description (all locales), and release notes (en/es/de/pl/fr) are updated, and the i18n keys for the removed interface and health check are dropped.

Existing installs

  • A signed-in node stays signed in. Its identity is tailscaled.state on the main volume, which this change doesn't touch, and its serves keep working.
  • The Tailscale Admin interface disappears, along with any domain the owner attached to it. The release notes say so.
  • An install that was never signed in gets the Sign In task.

Verification

  • npx tsc --noEmit is clean.
  • rm -rf javascript && make javascript/index.js is clean.
  • prettier --check is clean.
  • The commands and JSON fields come from the Tailscale v1.104.7 source (cmd/tailscale/cli/up.go, logout.go, ipn/ipnstate).
  • Not box-tested. Nothing has been installed or run on a StartOS server. In particular, the sign-in flows, the pending-login-survives-CLI-exit behaviour, and the Log Out restart haven't been exercised.

@tobomobo @kwsantiago, could you review this?

review effort: 'high'

🤖 Generated with Claude Code

`tailscale web` was bound to 0.0.0.0:8240 and exported as the Tailscale
Admin UI interface. On generic Linux the web client applies no login, and
its login API can sign the node in to any tailnet or control server, or
re-authenticate it. Upstream's own default is localhost-only.

The web client is no longer run and the `web` host is retired in the
1.104.7:1 migration. Signing in and checking the node move to actions that
run the tailscale CLI in a temporary subcontainer against tailscaled's
socket on the main volume:

- Sign In: `tailscale up --reset --json [--login-server]`, returning the
  AuthURL (copyable, QR, launchable). `--force-reauth` when the node
  still holds a key.
- Sign In with Auth Key: the same with `--auth-key=file:` (masked input,
  key never on the command line).
- Node Status: `tailscale status --json --peers=false`.
- Log Out: `tailscale logout`, rewrite ts-status.json, restart.

An important task points to Sign In while ts-status.json does not
record Running, and is cleared once it does. Existing signed-in nodes keep
their identity in tailscaled.state and stay signed in.

Bumps start-sdk 3.1.1 -> 4.1.0 (no code changes needed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MattDHill
MattDHill marked this pull request as ready for review November 20, 2026 17:50

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two correctness fixes before approval:

  • [P2] Preserve command failures in withTailscaleCli (startos/utils.ts:226, startos/actions/logOut.ts:21–29). SDK 4.1.0's sub.exec resolves on nonzero exit and timeout; the wrapper discards those fields. Consequently Log Out reports success and restarts even if tailscale logout fails (for example, the control-server logout request fails or times out), or the status rewrite fails. The owner cannot tell that the requested logout/key invalidation did not complete. The proposal uses execFail at the shared command boundary, documents its rejection contract, and routes status queries through that same primitive. The sign-in script's intentional termination of tailscale up is unaffected: the shell still finishes by copying its captured output.

  • [P2] Decode the JSON string before returning the sign-in URL (startos/utils.ts:296). Upstream v1.104.7 uses Go's json.MarshalIndent for AuthURL (cmd/tailscale/cli/up.go:774). A valid control-server authorization URL such as https://login.example/auth?node=x&state=y therefore contains \u0026 in stdout. The regex currently returns that escaped text verbatim, and its truthiness prevents the already-decoded status fallback from being used. The launch button and QR code then carry the wrong query string. The proposal captures the JSON string token and decodes it with JSON.parse, including escaped quotes/backslashes.

The removal of the unauthenticated web daemon, host retirement, state preservation, task registration and owner-only action access look sound. I also checked upstream's pending-login ownership: stopping the CLI does not cancel daemon-owned authentication. The head merges cleanly into current master; x86 and arm CI builds passed.

Proposed changes: 02925df...proposal/26

The proposal is unexecuted: no build, typecheck, tests or VM run during review. Please verify adopted changes, including a failed logout and a sign-in URL containing JSON escapes.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

Comment thread startos/actions/logOut.ts Resolved
Comment thread startos/utils.ts Resolved
Run action commands through execFail, so a failed or timed-out
`tailscale logout` (or status rewrite) fails the action instead of
reporting success and restarting. Decode the AuthURL JSON string, since
Go's encoder escapes `&` as `&` in the printed URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MattDHill

Copy link
Copy Markdown
Member Author

Adopted both points from proposal/26 as-is, in c80bd40.

  • Command failures. withTailscaleCli's exec now uses execFail, and status() goes through it. A failed or timed-out tailscale logout, or a failed status rewrite, now fails Log Out with the error instead of reporting success and restarting. Sign In is unaffected: its wrapper script ends with cat, so it exits 0 after the backgrounded tailscale up is stopped, and up's stderr is still returned. tailscale status --json exits 0 in every backend state (v1.104.7 status.go returns right after printing the JSON), so the stricter status call doesn't break the logged-out paths.
  • AuthURL decoding. The URL is captured as a JSON string token and passed through JSON.parse, so a & from Go's MarshalIndent comes back as &. I checked it in node against a URL with & and an escaped quote.

npx tsc --noEmit, rm -rf javascript && make javascript/index.js and prettier --check are clean. Still not box-tested.

helix-white added a commit that referenced this pull request Nov 20, 2026
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two earlier findings are fixed correctly in c80bd40: command failures now reject through the shared execFail boundary, and the AuthURL is decoded as a JSON string. The head still merges cleanly into master.

One remaining [P2] finding, also raised by @kwsantiago: preserve a node awaiting device approval when either sign-in action is repeated (startos/utils.ts, signIn). NeedsMachineAuth is a reachable, already-authenticated state with a node key. The helper only protects Running, so repeating Sign In takes the HaveNodeKey → --force-reauth path. Upstream v1.104.7 then calls StartLoginInteractive (cmd/tailscale/cli/up.go:695–696), starting authentication again instead of leaving the pending device alone. Following the sign-in prompt again while waiting for admin approval should not start replacing the identity being approved.

The proposal returns the existing status before invoking tailscale up when it is NeedsMachineAuth. Both actions then reuse their existing Waiting for Approval result, without resetting preferences, consuming an auth key, or starting a fresh login. Switching accounts remains available through Log Out. It records the pending-identity contract at the shared helper and updates README/instructions.

Proposed changes: c80bd40...proposal/26

No build, tests, typecheck or VM run during review; the proposal is unexecuted. Please verify repeat Sign In and Sign In with Auth Key in NeedsMachineAuth preserve the pending device, then approve that device and confirm it reaches Running.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MattDHill

Copy link
Copy Markdown
Member Author

Adopted the proposal: signIn now returns the existing status when the node is in NeedsMachineAuth, so repeating either sign-in action leaves a device that's awaiting approval alone. Typecheck and build are clean. Not box-tested: the approval flow needs a tailnet with device approval enabled.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 25e980a against the previous review. All three findings are resolved: CLI failures propagate, sign-in URLs are JSON-decoded, and both sign-in actions preserve an existing device awaiting approval. The pending-approval guard precedes all preference changes and auth-key writes, and the contract and user documentation match. No remaining correctness findings. The head merges cleanly into current master.

No builds or tests run during review. Current x86/arm CI builds are still running; the author explicitly records that the approval flow has not been box-tested.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@MattDHill
MattDHill merged commit 43a5671 into master Nov 20, 2026
3 checks passed
@MattDHill
MattDHill deleted the fix/sign-in-actions branch November 20, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants