Skip to content

Sign other devices in to bb, enforced by a Require sign-in switch - #8146

Merged
ymichael merged 32 commits into
mainfrom
bb/6748-ship-auth-for-non-local-routes-lan-tailscal-thr_vgxkkdbhmq
Dec 2, 2026
Merged

ymichael merged 32 commits into
mainfrom
bb/6748-ship-auth-for-non-local-routes-lan-tailscal-thr_vgxkkdbhmq

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb answered its API, /ws and plugin routes for anyone who could reach the port, and trusted a request to come from the server machine if it arrived from loopback. That is unsafe as soon as bb is reachable from anywhere but loopback: a LAN bind (--server-bind-host 0.0.0.0, the new Local network route), Tailscale Serve, or a reverse proxy. All of these reach the server from loopback, and nginx's default proxy_pass or a socat-style forwarder hides the real client completely. A LAN peer could also forge the x-bb-gate-* headers that the bb connect gate sets. So bb had no way to require that a remote device sign in, and no sign-in that a proxy on the server machine couldn't bypass.

What changed

Sign-in is now built in, but it is enforced only while two switches are both on:

  • the existing serverRoutes experiment, now labelled Multiple server routes and device sign-in. It already lets machines fail over between routes; it now also adds Settings → Devices. It keeps its key, so it stays on for early adopters and anyone's own choice is kept;
  • its Require sign-in setting, a stored setting off by default, changed in Settings → Devices, with bb access require-sign-in or the API.

Changing the experiment either way turns Require sign-in off, including when leaving early adopter changes it, so the experiment alone never starts enforcing sign-in. With either off, bb behaves as it does today. Early adopters see Settings → Devices, but nothing is enforced until someone turns Require sign-in on.

Who sent a request. One resolver (apps/server/src/request-access.ts) decides, and nothing is trusted for its address:

  • bb connect. The connect plugin stamps a per-start tunnel marker on its requests. Without that marker, every x-bb-gate-* header is deleted before any route sees it.
  • The server machine. Its CLI, agents, scripts and launcher send a local token from <data dir>/local-access-token (mode 0600). Running plugins send their caller token, and in-process requests need nothing.
  • Native clients (the mobile app, the desktop app on a remote server, a CLI on another computer) get device-bound tokens.
    • Pairing: a one-time code is redeemed with a DPoP proof (ES256, RFC 7638 thumbprint).
    • Tokens are 1-hour HMAC access tokens bound to the device's key, with a 30-day sliding session.
    • /ws opens with a 5-minute ticket plus a proof.
    • The device's WebView gets a cookie of at most 1 hour that dies with the device.
  • Browsers get an HttpOnly cookie, bb_session_<port>, that expires after 30 days without use. A sign-in made over HTTPS is refused over HTTP.
  • Execution machines use their host key. The daemon's loopback proxy now signs agents' requests over whichever server route is active.
  • The enroll-key endpoint needs the local token while Require sign-in is on. While it is off, a loopback request without a credential still works, as on main, so bb-app host-daemon join without --join-code works for a daemon in any data directory. With the switch on, a daemon in another data directory joins with --join-code/--host-id, like a remote machine; the tarball smoke mints that code with the server machine's token.

Gate off (the default). A request without a valid credential becomes {owner, via: "open"}. That is today's behaviour, and a stale cookie or a foreign token is ignored rather than refused.

Gate on. Everything above is required.

Turning it on never locks out the caller. PUT /api/v1/access/require-sign-in, sdk.experimental_access.setRequireSignIn, bb access require-sign-in on|off, Settings → Devices → Require sign-in, and the Experiments and early adopter switches when they turn sign-in off, all go through one function:

  • while the experiment is off, turning it on gets 409 server_routes_experiment_disabled, and nothing is signed in;
  • a caller that isn't signed in gets 409 sign_in_this_device_first, and the flag doesn't change. Settings → Devices then signs its browser in with a one-time pairing code and retries, and a CLI pairs itself the same way. The cookie is stored before sign-in is enforced, so no request from that browser can race it: setting the cookie in the same response let the websocket's config-changed refetch, which can arrive first over bb connect, go out without it and show the sign-in screen;
  • machines get 403.

Local network. The Local network route opens its listeners and is advertised only while sign-in is required. Its warning now says devices on the network sign in but the traffic isn't encrypted.

Surfaces.

  • Data: new access_credentials table (migration 0173_access_credentials).
  • API and SDK: /api/v1/access/* routes; sdk.experimental_access; bb access pair|login|logout|status|require-sign-in|list|revoke.
  • App: Settings → Devices, shown only with the serverRoutes experiment, with a note under the Sign-in heading about what Require sign-in changes, and a QR pairing code; a sign-in screen; mobile pairing by code with a device key. Updated mobile apps that were already signed in through their web view adopt a device key on their own.
  • Desktop: the local window gets a local-token session, and remote servers are paired with a device key.

Review fixes (from the review in @thread:thr_pngnsm6zfh):

  • A valid pairing code always redeems; only wrong guesses count toward the limit, so junk codes can't block pairing.
  • DPoP proofs are checked against the raw request path, so paths like app/%5Bid%5D/page.tsx work for devices.
  • The CLI writes server-credentials.json atomically.
  • The wildcard-bind startup warning only appears while Require sign-in is off.

Wire and version bumps.

  • HOST_DAEMON_PROTOCOL_VERSION 286 → 287: the daemon proxy signs with the host key, and enroll-key needs the local token.
  • Plugin SDK 0.6.218: bb.server.experimental_tunnelMarker, offered to every plugin so any tunnel plugin can vouch for who its gate let in; the bb.http.route option experimental_oauthScope, with which core also admits gate OAuth clients holding that scope (the MCP route uses "bb" and no longer checks access itself); and the devices settings section. No internal_DO_NOT_USE_ members are added.
  • Mobile bridge v6: the renew-session and adopt-device requests, and a deviceAccess handshake field (sign-in or adopt). Device sign-in is a separate field rather than new capability names because older pages reject a handshake with a capability they don't know; pages now drop unknown native capabilities instead.
  • App boot payload: the sign-in gate loads on boot because the app must decide before it renders; the sign-in screen and Settings → Devices load on demand, and DPoP signing and pairing error copy are off boot. It fits main's limit (411.1 KB of 419.1 KB brotli), so the budget is unchanged.

Docs. docs/multiple-devices.md, the bb guide machines and customization chapters, the bb-cli command index, and docs/api_to_audit.md. Ladle's dev proxy now adds the dev server's token only for a loopback browser with no forwarding headers.

With the gate on, users of older clients see this:

  • Older bb mobile builds (no device sign-in):

    • Adding a new direct server fails at the probe step with "HTTP 401".
    • Existing direct profiles show the sign-in screen and can pair the WebView with a code.
    • On iPhone, push for HTTPS direct servers stops re-registering after 24 h, because native requests don't share the WebView cookie. Android likely recovers once the WebView pairs.
    • Profiles added through bb connect are unaffected.
    • After updating, the app adopts a device key from its signed-in WebView on first launch.
  • The 11 catalog plugins that call the API directly instead of through bb.sdk get 401:

    Plugins Call
    inbox, ntfy raw connect/rpc/status; links fall back to 127.0.0.1
    automation-groups automations RPC
    factory-droid system/config/reload
    miku tasks RPC
    plugin-vault catalog search
    handsfree /plugins/<id>/cli
    wikilinks file previews for media
    account-pool-balanced the "Update pool" script
    iris auth: "local" feeds
    meetings selftest only
    korey, my-jira OAuth callbacks on auth: "local" routes

    With the gate off, which is the default, every one of them works as before.

Part of #6748

How you verified

Kill tests (apps/server/test/security/require-sign-in.test.ts, plus request-access, local-proxy-kill, device-dpop with the gate on). With sign-in forced always on, the gate-off and turn-on tests fail; they pass with the change.

  • Gate off: a LAN browser, an old-mobile probe, a raw loopback plugin call and a stale or foreign credential all get 200. The Local network route stays closed.
  • Gate on: a LAN peer, nginx-style proxy_pass, a socat-style forwarder and a stale cookie all get 401.
  • A browser or CLI that isn't signed in gets 409 and no cookie, and sign-in stays off; a browser signed in with a pairing code turns it on and keeps working. The local token flips it both ways; a machine gets 403.
  • The experiment alone, or a stored Require sign-in without the experiment, enforces nothing. Turning it on while the experiment is off gets 409 and sets no cookie. Changing the experiment, directly or by leaving early adopter, turns sign-in off, and a machine credential can't use the experiment to do that (403). Breaking either rule fails these tests.

Checks (one experiment, pair-first sign-in, ae616f2). Server security, system, machines and plugin wire/SDK tests 472/472; @bb/app settings and views 986 passed. Typecheck and lint pass on the affected packages. Removing the early adopter handling fails the new test. Through a local proxy that delays responses like bb connect: before, a delayed PUT let the refetches go out without a cookie (401) and the sign-in screen showed, and the switch went false → true → false → true; after, the PUT gets 409, the page pairs and retries, every refetch gets 200, and the switch flips once.

Checks (two-switch change, 67764eb). Server security, system, machines and plugin wire/SDK tests 562/562; @bb/app settings, views and access state 987 passed; @bb/cli 1476; @bb/templates 47; @bb/demo-server 15; @get-bb/plugin-sdk 512. Typecheck and lint pass on the 10 affected packages. Live on a QA server: with the experiment off, bb access require-sign-in on gets the 409 and leaves no sign-in behind, and Settings → Devices is hidden and redirects; with it on, uncredentialed requests still get 200 until Require sign-in is on (then 401); turning the experiment off from Settings → Experiments drops back to 200, and turning it on again keeps 200.

Checks (earlier rounds). pnpm exec turbo run typecheck lint test --filter='...[origin/main]': 275/276 tasks pass. The one failure is @bb/app exclusive-pick-first-paint.test.ts, a 15 s timeout under a load average above 40 on code this branch doesn't touch; it passes alone (7/7). apps/server/test/security: 48/48, including the 9 require-sign-in kill tests.

Live, isolated pnpm start --server-bind-host 0.0.0.0, LAN 192.168.4.28:

Request Gate off Gate on
LAN GET /api/v1/system/config (old mobile add-server probe) 200 401
LAN GET /api/v1/projects, no credential 200 401
LAN GET /api/v1/projects, stale cookie 200 401
loopback POST /system/config/reload (factory-droid) 200 401
loopback GET /threads/running (account-pool script) 200 401
loopback POST /plugins/connect/rpc/status (inbox, ntfy) 200 401
LAN MCP initialize 200 401
nginx default proxy_pass → /projects 200 401
socat-style forwarder (Host 127.0.0.1) → /projects 200 401
loopback MCP with the local token 200 200

Pair-on-enable:

  • CLI on another computer, never signed in. bb access require-sign-in on printed Signed this CLI in as "bb CLI on Michael-M4.local" (acc_…) so it keeps working. After that, bb access status returned "Signed in: signed-in device" and bb project list succeeded.
  • LAN browser, never signed in. It clicked Settings → Devices → Require sign-in. The PUT got 409 sign_in_this_device_first, the page redeemed a fresh pairing code (HttpOnly bb_session_<port> cookie), and the retried PUT returned 200. It stayed in with the switch on, and a fresh browser saw "Sign in to this bb".
  • Raw PUT with no Origin and no credential. It returned 409 sign_in_this_device_first, and the gate stayed off.
  • Local network route (loopback-bound server). Added with the gate off, bb listened only on 127.0.0.1, LAN /health got no answer, and the route's status said to turn on Require sign-in. After on it also listened on the LAN address (/health 200, /projects 401). After off the LAN listener closed.

Earlier rounds, live:

  • packaged desktop: local window, a custom remote server, revoke;
  • iOS Simulator Release build: pairing and revoke;
  • device-key adoption: a signed-in browser posing as the app handed over a code, which a real DPoP key redeemed (not re-run on the simulator);
  • agents' bb through the daemon proxy;
  • the launcher sign-in link.

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/6748-ship-auth-for-non-local-routes-lan-tailscal-thr_vgxkkdbhmq branch 2 times, most recently from 6328afc to b975e48 Compare November 24, 2026 22:56
ymichael added a commit that referenced this pull request Nov 25, 2026
…details (#8150)

## Human comments

## What was wrong

The GitHub PR Status plugin's branch lookup
(`plugins/github-pr-status/host/git-host.ts`) asked GitHub for up to 100
PRs on the branch, each with every detail field: `reviewRequests(first:
100)`, `commits(last: 1)` and `statusCheckRollup.contexts(first: 100)`.
GitHub prices a query by the most it could return, so every lookup cost
3 points even on a branch with no PR, and 25 environments in one
document cost 75 points. Repeated across many environments, that used up
the 5,000-point hourly GraphQL allowance shared with every `gh` call on
the machine (#5704; measured by cameronm123 on 0.50.1). The same query
also timed out after 10 s on head names shared by many fork PRs (for
example `main` in `microsoft/vscode`), so in those cases it never
covered 100 PRs.

## What changed

- The branch scan still lists the branch's 100 newest PRs, but only with
the fields `matchesBranchTarget` needs (`url state isCrossRepository
headRepositoryOwner`). The same repository selection adds `newest:
pullRequests(..., first: 1)` with full details.
- If the matched PR is the newest one, its details are used directly.
Otherwise the match is read again by URL, the same path used for PRs bb
already knows.
- `reviewRequests(first: 0) { totalCount }`: only the count is used.
- The 500,000-node document splitting is removed because it can no
longer trigger (a 25-branch document is about 5,000 nodes). Documents
are still capped at 25 reads.
- README batching paragraph updated.

This differs from the issue comment's proposal (`first: 5/10/50`). A
5-PR page misses the right PR when newer fork PRs share its head name
(on `microsoft/vscode` `main` the matches were at positions 9, 12 and
22). Smaller `reviewRequests` or `contexts` pages save no points,
because cost depends only on the number of connection requests.

No wire, CLI or protocol changes.

## How you verified

- Cost, priced with `rateLimit(dryRun: true)` on the exact query the
plugin sends (captured through a `gh` shim):

  | Branch lookups in one document | Before | After |
  |---|---:|---:|
  | 1 | 3 pts (20,200 nodes) | 1 pt (203 nodes) |
  | 10 | 30 pts | 1 pt |
  | 25 | 75 pts | 1 pt (5,075 nodes) |

- Latency on real GitHub, median of 5 runs: a branch with a PR takes 847
ms before and 780 ms after. A branch with no PR takes 432 ms before and
516 ms after; I read that as noise and didn't investigate further.
- Old vs new code against real GitHub for 9 branch targets (same-repo
open, same-repo none, default branch, and 6 fork-owner targets on
`microsoft/vscode` `main`) plus 3 URL reads. Where the old code returned
a result, the new code returned the same PR, state, check count and
review-request count. The 5 fork-heavy targets the old code timed out on
now resolve. Two of them reported a different merge state (BLOCKED, then
UNKNOWN) on a later run; GitHub computes merge state lazily.
- End to end on `pnpm start:worktree`: `bb pull-request show` on a
project-checkout environment for #8146's branch found the PR through
branch discovery.
- New tests:
- `host.test.ts`, "finds the branch's PR behind many newer PRs from
other forks with the same head name": fails when the scan page is cut to
5.
- `host/batch.test.ts`, "reads 25 branch lookups in one document with
details for only each branch's newest PR": fails if the detail fields go
back into the 100-PR scan.
- `pnpm exec turbo run test typecheck lint
--filter=bb-plugin-bb--github-pr-status`: 183 passed.

Fixes #5704

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/6748-ship-auth-for-non-local-routes-lan-tailscal-thr_vgxkkdbhmq branch 5 times, most recently from 3e7c661 to 118740e Compare December 2, 2026 18:36
ymichael and others added 21 commits December 2, 2026 11:22
…rver machine

bb's browser API, /ws and local plugin routes answered anyone who could reach
the port, and x-bb-gate-* headers were trusted by presence, so a LAN peer could
claim to be a bb connect machine or an OAuth MCP client.

One resolver now decides who sent each request:
- the server machine (loopback peer, loopback Host, every proxy hint loopback)
  is the owner with no setup;
- a request stamped with this start's tunnel marker carries the bb connect
  gate's verdict; without the marker every x-bb-gate-* header is deleted;
- anything else needs a sign-in (cookie or bbs_ bearer) from a single-use
  pairing code, or a daemon host key (machine).

Adds access_credentials, /api/v1/access/* (session, pairings, redeem,
credentials, sign-out), sdk.experimental_access, the connect plugin's marker
via bb.server.internal_DO_NOT_USE_tunnelMarker, and MCP's check on
bb.http.internal_DO_NOT_USE_requestAccess. A sign-in made over HTTPS is
refused over plain HTTP; revoking one closes its sockets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…host key

A daemon enrolled on a LAN or tailnet address started no loopback CLI proxy, so
agents' `bb` reached the server bare and is now refused. The proxy now also
runs whenever the server URL is not loopback and adds the daemon's host key as
a bearer, which the server treats as a machine principal. Bumps
HOST_DAEMON_PROTOCOL_VERSION so enrolled daemons update before their agents
start getting 401s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`bb access pair` mints a one-time code on a trusted surface; `bb access login
--code` signs a remote CLI in to BB_SERVER_URL and stores the token per origin
in <data dir>/server-credentials.json (0600), so it is only ever sent to the
origin it was minted at. `list`, `revoke`, `status` and `logout` cover the rest.
The CLI's HTTP and realtime requests carry the stored bearer.

Also reserves `access` as a core command name, documents the commands in the
machines guide chapter and the bb-cli command index, and makes the SDK access
area resolve its routes lazily like the other areas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shell now always carries {"authenticated": true|false}, so the app can tell
a signed-in shell from a dev server that serves its own index.html. Also types
the access test fixtures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shell that says the browser is signed out, or any 401 unauthenticated or
credential_requires_https from the API, swaps the app for a pairing screen that
redeems a code (typed, or from a /pair#code=… link) and reloads signed in.
Settings → Devices lists signed-in devices with Revoke / Sign out, and "Sign in
another device" shows the code, a QR code of the link and a countdown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A direct server that answers 401 unauthenticated now asks for a pairing code at
add-server, redeems it as a device, stores the token on the profile and installs
it as the session cookie in the native and WebKit stores, so the WebView,
native fetch and realtime all carry it. A revoked sign-in moves the profile to
auth-required with "Sign in again". Profiles saved before this load with
access: null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/multiple-devices.md explains who is let in without signing in, how to
pair a browser, phone or CLI, the HTTPS rule and reverse-proxy requirements.
docs/api_to_audit.md records sdk.experimental_access and the two internal
members the connect and MCP plugins use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A revoked browser or desktop kept showing the app on cached data: the
server closes the revoked credential's /ws (4401) and refuses every
reconnect, but the app only flipped to the pairing screen on an HTTP 401,
and nothing issues one while the user just looks at the page.

The realtime manager now reports every socket loss, and the app checks
GET /api/v1/access/session on each one (one request in flight at a time).
When the server no longer signs this device in, the pairing screen shows
with the server's reason. Network failures (a restarting server) keep the
app signed in and the next loss checks again, so a server that comes back
after a revoke is still caught.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unauthenticated 401 said "open it in a browser", which is wrong for a
remote CLI (it needs bb access login --code) and for a tab already open on
a pre-upgrade bundle (it needs a reload). The message now names both.
The mobile sign-in copy showed literal backticks in native text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a device key

Loopback peer + loopback Host + loopback-only proxy hints made a request the
owner. nginx's default proxy_pass (Host rewritten to 127.0.0.1, no
X-Forwarded-For) and any TCP forwarder (socat, haproxy tcp, ssh -R) where the
client sets Host hand that to a remote client. Every request now needs a
credential whose boundary is file permissions or process ownership:

- the server machine's local token in <data dir>/local-access-token (0600),
  sent as Authorization: Bearer bbl_…; /internal/hosts/enroll-key needs it too
  instead of a loopback-peer check;
- a running plugin's caller token, which bb.sdk HTTP and /ws now send;
- in-process requests with no socket.

Native clients get device-bound sessions in T3 Code's shape: a device redeems a
pairing code with a DPoP proof (ES256, RFC 7638 thumbprint), gets a 1-hour
HMAC-signed access token bound to its key, sends Authorization: DPoP + a proof
per request, renews at /api/v1/access/token with the same key (30-day sliding
session), and opens /ws with a 5-minute ticket plus a proof. A bound token as a
bearer, a missing, foreign or replayed proof all fail closed. Their WebViews
get a <=1 h child cookie (/access/device-browser-sessions) that dies with the
device. The desktop's local window gets a cookie from /access/local-sessions
(replaced on re-mint). Browser cookies last 30 days without use.

Kill tests: an nginx-style proxy, a socat-style forwarder and a bare loopback
request all get 401; a captured device token is useless without its key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rust

- The CLI sends the local token to a loopback BB_SERVER_URL (read from
  BB_DATA_DIR or ~/.bb), through every request path including raw fetches and
  bb terminal attach. `bb access login` now creates a P-256 key, redeems with a
  DPoP proof, signs every request and renews its hour-long token itself.
  `bb access pair --open` opens a one-time sign-in link locally.
- `npx bb-app` prints a one-time sign-in link when it starts in a terminal and
  sends the local token on config reload and enroll-key calls.
- A host daemon whose data dir has no local token (a second daemon on the
  server machine) runs the loopback CLI proxy with its host key, so its agents
  are the machine principal.
- `pnpm bb:dev` sets BB_DATA_DIR for the dev instance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… with a device key

- The desktop's main process reads the local token from the data dir of the
  server it starts or attaches to, sends it on every main-process call to that
  server (probes, system config sync and its /ws, connect RPCs, browser broker)
  and never to another origin. Before loading the window it creates a local
  browser session (/access/local-sessions) if the jar's cookie no longer works,
  so desktop users see no sign-in screen.
- On a custom (direct) server the app's sign-in screen hands the code to main
  (bb-desktop pairServer), which keeps a P-256 key per origin encrypted with
  safeStorage, redeems with a DPoP proof, renews the token and re-mints the
  window's <=1 h cookie about every 45 minutes.
- Inside a mobile shell that signs in with a device key, the sign-in screen asks
  the app to renew the web view's session instead of taking a code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A direct profile's sign-in now keeps a P-256 key (noble) in the secure store,
redeems the pairing code with a DPoP proof, signs native requests (probe, push
RPC, thread probe) with per-request proofs, opens realtime with a ticket plus a
proof, and renews its hour-long token itself. The WebView, which cannot hold a
key on a plain-HTTP origin, gets a <=1 h cookie minted by native and renewed
about every 45 minutes and on foreground. Bridge v5 adds the device-sign-in
capability and a renew-session request for the page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Integration, render-invariants, QA, Ladle, bb-app smoke, desktop AppImage smoke
and mobile e2e reached the server as loopback. They now send the local token,
sign Playwright in through /access/local-sessions, and mint pairing codes for
the mobile e2e flows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
multiple-devices.md lists what credential each client uses and how to get it,
session lifetimes and the plain-HTTP rule; the machines guide chapter covers
the local token, `bb access pair --open` and key-bound `bb access login`;
debugging-and-qa.md and the verify-bb doctor show how dev browsers and scripts
sign in; api_to_audit.md updates the access SDK and internal plugin members.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… browser

Ladle's /api and /ws proxy added the dev instance's local token to every
request, so anyone who could reach Ladle (a bb connect share, the LAN) got
owner access to the dev server. It now attaches the token only to requests
that reached Ladle over a loopback socket with a loopback Host and no
forwarding headers (shares arrive through Cloudflare with cf-connecting-ip),
and it drops any Authorization a client sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A direct server added by an older mobile build has a browser cookie in
its web view but no device key, so after the update push registration
and other native calls keep getting 401 until someone signs in again by
hand. The shell now offers device-adopt for such profiles; the signed-in
page mints a pairing code and the app redeems it with a fresh device key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Enforcing a credential on every request broke 11 marketplace plugins that
call the API directly, and stopped older mobile builds from adding a server
or re-registering iPhone push. Sign-in is now a standalone experiment,
requireSignIn, off by default and outside the early adopter set.

With it off, a request with no valid credential resolves to a new
{kind: "owner", via: "open"} access instead of anonymous, so everything works
as it did before, and a stale cookie or a foreign local token is ignored
rather than refused. Tunnel requests still carry the bb connect gate's
verdict. The plugin SDK's internal requestAccess gains "open", which the MCP
plugin serves like the server machine.

The Local network route's listeners and advertisement now also need
requireSignIn, so bb never opens to the LAN without sign-in.

PUT /api/v1/access/require-sign-in (sdk.experimental_access.setRequireSignIn,
bb access require-sign-in on|off, Settings → Devices → Require sign-in) turns it
on without locking out the caller: an open browser gets a session cookie in
the same request, an open non-browser caller gets 409
sign_in_this_device_first, and the CLI pairs itself first in that case. The
Experiments switch goes through the same function. Machines cannot change it.
The launcher prints its sign-in link only while sign-in is required.

Kill tests: with it off, LAN browsers, old mobile probes, plugins' raw
loopback calls and stale cookies get 200; with it on, a LAN peer, nginx's
default proxy_pass, a socat-style forwarder and a stale cookie get 401;
turning it on from a browser or the Experiments switch keeps that browser in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d pages, open join

- A valid pairing code always redeems; only wrong guesses count toward the
  limit, so junk codes from the network can no longer block pairing.
- DPoP proofs are checked against the raw request path, so paths with
  percent-encoded characters like `app/[id]/page.tsx` work for devices.
- The mobile app advertises device sign-in in a new `deviceAccess` bridge
  field instead of new capability names, which older pages rejected along
  with the whole handshake. Pages now drop native capabilities they don't
  know instead of rejecting the handshake.
- While Require sign-in is off, enroll-key accepts this machine's loopback
  requests without the local token, as before, so `host-daemon join`
  without `--join-code` works for a daemon in another data directory.
- The CLI writes server-credentials.json atomically.
- The wildcard-bind startup warning only appears while Require sign-in is off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oute OAuth scopes

- bb.server.internal_DO_NOT_USE_tunnelMarker becomes
  bb.server.experimental_tunnelMarker, offered to every plugin, so a tunnel
  plugin other than bb connect can vouch for who its gate let in. A gate
  verdict can only lower a request's access, and plugins already act as the
  owner, so the value grants nothing new.
- bb.http.internal_DO_NOT_USE_requestAccess is gone. A route with auth
  "local" can add experimental_oauthScope; core then also admits OAuth
  clients a gate let in with that scope and answers others with 403 before
  the handler runs. The MCP plugin's /mcp route uses it with scope "bb" and
  drops its own access checks.
- Docs: api_to_audit entries, Plugin Guide symbols, the authoring reference,
  and the pairing limit wording (a correct code still works).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael and others added 10 commits December 2, 2026 11:22
…equire sign-in as its own setting

The Experiments page and Settings → Devices had two switches for the same
flag. The `deviceSignIn` experiment now only decides whether Settings → Devices
exists; Require sign-in is a stored setting changed from that page,
`bb access require-sign-in` or the API. Sign-in is enforced only while both are
on, and changing the experiment turns Require sign-in off through the same
lockout-safe path, so the experiment alone never starts enforcing sign-in.
Turning Require sign-in on while the experiment is off is refused with 409
`device_sign_in_experiment_disabled`; the CLI tries the switch before pairing
itself, so it never leaves a pairing behind.

Settings → Devices loses most of its copy: a "Why require sign-in?" banner
explains the switch and what needs an update, the switch and the pairing code
share one card, and device rows fit on two lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… tests their experiments

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The code button stays on the "Sign in another device" row on phones and turns
into Done once a code is showing. The code sits in a recessed card that stacks
the QR above a full-width code on narrow screens and puts the text beside the
QR, top-aligned, on wider ones, with the same countdown and "works once" lines
as Settings → bb connect → Pair your phone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Turning Require sign-in on from an open browser used to set the browser's
cookie in the same response that turned it on. The server also pushed
config-changed over the websocket, and over bb connect that push could
arrive first: the refetch it triggered went out without the cookie, got
401 and showed the sign-in screen until a reload.

The server now refuses an open caller with 409 sign_in_this_device_first,
as it already did for the CLI, and Settings → Devices pairs the browser
with a one-time code and retries, so the cookie is stored before sign-in
is enforced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The switch fell back to the cached system config as soon as the change
finished, before the config refetch landed, so on a slow connection it
showed the old value for a moment. Write the result into the cached
config instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One experiment, "Reach bb from other machines and devices", now covers
machine routes, Settings → Devices and Require sign-in, so the Local
network route can no longer point at a Devices page that is hidden. It
keeps the shipped serverRoutes key, so early adopters keep their value
and see Settings → Devices; nothing is enforced until Require sign-in
is turned on. Turning the experiment off or on, including through the
early adopter switch, turns Require sign-in off. The Local network
warning now says devices sign in but the traffic isn't encrypted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main published 0.6.217 after this branch claimed it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/6748-ship-auth-for-non-local-routes-lan-tailscal-thr_vgxkkdbhmq branch from 118740e to ae616f2 Compare December 2, 2026 19:25
@ymichael
ymichael merged commit 40401e0 into main Dec 2, 2026
55 checks passed
@ymichael
ymichael deleted the bb/6748-ship-auth-for-non-local-routes-lan-tailscal-thr_vgxkkdbhmq branch December 2, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant