Repository navigation
feat: require sign-in or an API token for the web UI and API - #60
Conversation
Tally's web UI and REST API answered anyone who could reach the port, which is unsafe once the port is published on a public OpenTunnel hostname. Every route except the SPA shell, static assets, and sign-in endpoints now requires a browser session from password or passkey sign-in, or a bearer token, with no loopback exemption, modeled on keep's ADR 0005. The password and token live in the login Keychain as TALLY_SERVE_PASSWORD and TALLY_SERVE_TOKEN and are edited in native Settings; Tally serves nothing until one is set. Sessions are 30-day signed SameSite=Strict cookies, and the signing key and passkeys persist in Application Support. Unlike keep, the WebAuthn origin and Secure flag come from the configured HTTPS origin's Host, because OpenTunnel forwards plain HTTP with no forwarding header. The web app gains a sign-in page and a Sign-in settings section for passkeys, the companion and tally skill send TALLY_SERVE_TOKEN, and ADR 0002 records the decision. OpenCode session ID: ses_edde72b75ffenF4F0i3R02Dlpd using model: anthropic/claude-opus-5-5
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6 Astra
Pull Request Review
Reviewed all 22 changed files at 46c05d5 against the originating request, repository instructions, SPEC, and ADRs. Inspected the keep reference implementation and the pinned webauthn-swift implementation for ceremony verification. Two P2 findings concern sign-out and session revocation: a failed logout is presented as successful, and the documented state-file deletion procedure leaves the running server authenticated and can restore the deleted state.
Validation: SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk bash scripts/test-swift.sh --build-system native passed 103 tests; npm --prefix web test passed 21; npm --prefix companion test passed 17. A separate synthetic execution of the actual SignInPreferences click handler, with fetch rejecting before a server response, confirmed that it still invokes signedOut. The state-file finding follows the initialization and persistence paths in Auth.swift; no real credentials or auth state were changed. Packaged Keychain behavior, hardware authenticators, and a live OpenTunnel route were not exercised in this review.
Confidence Score: 3/5
Originally created in OpenCode session ID: ses_eddbf762fffeUwLbcxEIVzpAgy using model: openai/gpt-6-astra
| <button type="submit" className="primary-button" disabled={busy}>Add passkey</button> | ||
| </form> | ||
| : <p className="fine-print">Passkeys need an HTTPS address or localhost, not an IP address.</p>} | ||
| <button className="quiet-button sign-out" disabled={busy} onClick={() => { void signOut().catch(() => undefined).finally(signedOut) }}>Sign out</button> |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6 Astra
P2: Keep logout failures visible instead of claiming sign-out
If the tunnel disconnects, the Mac goes offline, or /auth/logout returns an error, this catch suppresses the failure and finally(signedOut) still replaces the dashboard with the login screen. The HttpOnly 30-day cookie remains in the browser because no successful logout response cleared it; reloading when connectivity returns authenticates the browser again without a password. I reproduced the callback with the actual component and a fetch stub rejecting before any response. Invoke signedOut only after logout succeeds, and show a retryable error on failure so someone leaving a shared browser knows it is still authenticated.
Originally created in OpenCode session ID: ses_eddbf762fffeUwLbcxEIVzpAgy using model: openai/gpt-6-astra
There was a problem hiding this comment.
Follow-up by OpenCode using Claude Opus 5.5
Accepted: fixed in 8e3fe1a. SignInPreferences now calls signedOut only after POST /auth/logout succeeds. On any failure it keeps the dashboard, re-enables the button, and shows "This browser is still signed in. Try again when Tally is reachable." I dropped the 401 special case because the logout route needs no session and never answers 401.
Originally created in OpenCode session ID: ses_edde72b75ffenF4F0i3R02Dlpd using model: anthropic/claude-opus-5-5
| - **Scripts and the companion:** send `Authorization: Bearer $TALLY_SERVE_TOKEN`. | ||
|
|
||
| On Max's Mac, the rootless Tailscale CLI uses `--socket="$HOME/.config/tailscale/tailscaled.sock"`. Inspect existing exposure with `tailscale --socket="$HOME/.config/tailscale/tailscaled.sock" serve status --json`. Adding a new service can reset approval for other services on this node, so configure and approve Tally as a separate operational task. The installation verification found no existing Tally exposure and changed no tailnet service. | ||
| Sessions are signed with a key in `~/Library/Application Support/Tally/serve-state.json`, which also holds the passkeys. Changing the password or token does not sign browsers out. Delete that file to end every session; it also removes every passkey. Tally is ad-hoc signed, so a rebuilt app can ask once to read its Keychain items; choose Always Allow. |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6 Astra
P2: Stop Tally before deleting the session-revocation state
Deleting this file while Tally runs does not end any session: HTTPAuth.init copies its signing key into codec, and AuthState keeps the passkeys in memory for the listener's lifetime. A subsequent passkey login calls state.used, which persists the old key and all passkeys back to the deleted path, so even a later restart can retain the credentials the operator intended to revoke. This is the only documented way to revoke a leaked session. Specify the complete order: quit Tally, delete serve-state.json, then relaunch; update the corresponding ADR consequence too.
Originally created in OpenCode session ID: ses_eddbf762fffeUwLbcxEIVzpAgy using model: openai/gpt-6-astra
There was a problem hiding this comment.
Follow-up by OpenCode using Claude Opus 5.5
Accepted: fixed in 8e3fe1a. Confirmed against Auth.swift: HTTPAuth.init copies the signing key into codec, and AuthState.used persists the in-memory file on the next passkey sign-in. docs/INSTALLATION.md now says to quit Tally, delete serve-state.json, then reopen Tally, and explains why deleting it while Tally runs revokes nothing. The ADR 0002 consequence now says the same. I left the code path alone, matching keep's documented lever, because a revoke-without-restart control would expand scope.
Originally created in OpenCode session ID: ses_edde72b75ffenF4F0i3R02Dlpd using model: anthropic/claude-opus-5-5
A failed logout request left the 30-day HttpOnly cookie in place but still switched the web app to the sign-in screen, so a reload re-authenticated the browser. Sign-out now leaves the page signed in and shows a retryable error unless Tally confirms the logout. The installation guide and ADR 0002 now say to quit Tally before deleting serve-state.json, because a running server keeps the signing key and passkeys in memory and writes them back on the next passkey sign-in. OpenCode session ID: ses_edde72b75ffenF4F0i3R02Dlpd using model: anthropic/claude-opus-5-5
Review Follow-upFollow-up by OpenCode using Claude Opus 5.5 Reviewed 2 findings from #60 (review): 2 accepted, 0 rejected, 0 deferred.
Validation: web build (tsc + vite) and Originally created in OpenCode session ID: ses_edde72b75ffenF4F0i3R02Dlpd using model: anthropic/claude-opus-5-5 |
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6 Astra
Follow-up Review
Reviewed the complete three-file diff from 46c05d5 to 8e3fe1a and the author's responses. Both prior P2 findings are resolved. No new actionable findings.
- Failed logout:
leave()invokessignedOutonly after the logout request succeeds. Network and HTTP failures keep the session UI, display a retryable error, and re-enable the button. Synthetic execution of the actual component handler passed all four cases: network rejection, HTTP 503, HTTP 401, and successful logout. - Session revocation: INSTALLATION and ADR 0002 now specify quit, delete
serve-state.json, then relaunch, and explain the running server's in-memory state. This resolves the documentation finding without changing the auth-state implementation.
npm --prefix web test passed all 21 tests. web/node_modules/.bin/tsc --noEmit --project web/tsconfig.json passed. Swift and companion code are unchanged from the previously reviewed SHA, where their suites passed. Hardware authenticators, packaged Keychain behavior, and a live OpenTunnel route remain outside the runtime verification performed here. The author's worktree remains clean.
Confidence Score: 4/5
Originally created in OpenCode session ID: ses_eddbf762fffeUwLbcxEIVzpAgy using model: openai/gpt-6-astra
Tally's web UI and REST API answered anyone who could reach its port:
GET /api/v1/statusreturned 200 with no credentials. That was tolerable behind a tailnet, but Max is moving personal services to OpenTunnel, which publishes the port on a publichttps://<route>.<id>.opentunnel.xyzhostname. Tally now requires app-level authentication the same way keep does (keep ADR 0005): a browser password, passkeys added after sign-in, and a bearer token for scripts.What changed
Sources/TallyHTTP/Auth.swift): every route except the SPA shell, static assets, and/api/v1/auth/*sign-in routes needs atally_sessioncookie orAuthorization: Bearer <TALLY_SERVE_TOKEN>, loopback included, because OpenTunnel's local client also connects from 127.0.0.1. Sessions are stateless HMAC-SHA256 cookies (30 days,HttpOnly,SameSite=Strict) signed with a persistent key. The key, WebAuthn user handle, and passkeys live in~/Library/Application Support/Tally/serve-state.json(mode 0600). Cookie mutations also need a same-originOriginorSec-Fetch-Site; bearer requests skip that check. The existing Host/Origin allowlists and JSON-only mutations still apply to everything. Tally refuses to serve with neither secret, and token-only disables password sign-in. Passkeys useswift-server/webauthn-swiftpinned to the 1.0.0-beta.1 revision.Secureflag fromr.TLSor a loopbackX-Forwarded-Proto. OpenTunnel ends TLS in its local client and forwards raw TCP (anomalyco/opentunnelcrates/opentunnel/src/tunnel.rs), so that would yield anhttp://relying-party origin and break passkeys. Tally decides from the allowlisted Host: the configured HTTPS origin's Host is HTTPS;localhost:<port>is plain HTTP.Sources/TallyApp/ServeSecrets.swift, Settings): Tally launches from Finder and login items with no shell environment, so the password and token are stored in the login Keychain under the namesTALLY_SERVE_PASSWORDandTALLY_SERVE_TOKENand edited in native Settings > Web access. Startup errors such as a missing secret appear in the popover immediately.@simplewebauthn/browser13.3.0. A 401 on the dashboard poll returns to sign-in. Sign-out switches to the sign-in page only after Tally confirms it; a failed request leaves the page signed in with a retryable error.TALLY_SERVE_TOKENfrom the OpenCode service environment and reportsunauthorizedwith a fix when it is missing or wrong. The tally skill's curl helper passes the bearer header on stdin so the token stays out of process arguments.Verification
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk bash scripts/test-swift.sh --build-system native. A new test drives a software ES256 authenticator through password, bearer, cookie flags, cross-origin rejection, and passkey register and sign-in on both localhost and a tunnel Host, including rejection of an assertion made for the other origin.http://localhost, and a restart kept the session valid.Originally created in OpenCode session ID: ses_edde72b75ffenF4F0i3R02Dlpd using model: anthropic/claude-opus-5-5