Skip to content

feat: allow operator-trusted self-hosted account origins - #7626

Closed
toolittlecakes wants to merge 1 commit into
get-bb:mainfrom
toolittlecakes:feat/trusted-account-origins-v2
Closed

toolittlecakes wants to merge 1 commit into
get-bb:mainfrom
toolittlecakes:feat/trusted-account-origins-v2

Conversation

@toolittlecakes

@toolittlecakes toolittlecakes commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

The standalone account plugin accepts only getbb.app and staging in production, so bb account login --base-url https://bb.example.com and Connect's delegated code redemption cannot use an operator's own account/relay service. Passing a URL is intentionally not sufficient to grant it trust.

What changed

  • Add BB_ACCOUNT_TRUSTED_ORIGINS, a comma-separated list of additional exact HTTPS origins supplied in the server process environment. Validate the complete list and snapshot trust at account-plugin activation. Keep the existing default site and --base-url precedence/selection semantics.
  • Route account login, code redemption and Connect through the same account policy. Reject credentials, wildcards and non-origin inputs before sending a code. Validate the selected Connect --server origin before deriving its account origin, while preserving the general URL helper's existing behavior for other consumers.
  • Treat the managed environment key as startup-only, using the launcher's existing restart notice. Document packaged npx bb-app env set ... followed by explicit stop/start, plugin activation/reload behavior, trust implications and sign-out semantics. No database, daemon protocol, native UI, or relay deployment changes.

For example, persist BB_ACCOUNT_TRUSTED_ORIGINS=https://bb.example.com in the server service environment and restart that server; then use bb account login --base-url https://bb.example.com or bb connect --code <code> --base-url https://bb.example.com. The CLI flag itself cannot extend the allowlist. Removing an entry does not revoke a stored pairing; bb account logout does that.

How you verified

Rebased onto main at da3e60b81; the only conflict was the startup-only env key list in packages/bb-app/src/launcher.ts, resolved by keeping the new proxy keys and adding BB_ACCOUNT_TRUSTED_ORIGINS. Re-ran on the rebased branch:

VITEST_MAX_WORKERS=4 pnpm exec turbo run test typecheck \
  --filter=@bb/connect-client \
  --filter=bb-plugin-bb-account \
  --filter=bb-plugin-connect \
  --filter=bb-app \
  --concurrency=4
pnpm exec turbo run lint lint:type-aware --filter=@bb/connect-client --filter=bb-plugin-bb-account --filter=bb-plugin-connect --filter=bb-app

All four package suites passed: connect-client 28, bb-account 117, Connect 183 and bb-app 228 (556 tests), with all four typechecks (14/14 Turbo tasks). Lint and type-aware lint report 0 warnings and 0 errors; all 18 changed files pass oxfmt --check and git diff --check.

Integration tests use the default production plugin policy, real local HTTP handlers and a local WebSocket tunnel. They observe configured-origin success, the unchanged official default request URL, valid same-origin browser approval before foreign-link rejection, and zero attempted fetches for unknown/suffix-spoof/HTTP origins through account redemption, browser login.start and both Connect inputs. They also verify strict parsing, activation-time policy capture, no redemption redirect, selected --base-url precedence over an invalid unused --server, and the launcher's actual restart notice without a misleading reload message.

On the original branch, a bounded allow-all policy mutation made all 12 targeted denial tests fail across those four entry paths. Synthetic HTTPS names are mapped to deterministic loopback HTTP in test transport; public TLS/self-host/native E2E was not performed.

Supersedes #6307, which was auto-closed after two weeks without review (its only failed check was a Windows job that timed out downloading frp).

Fixes #5744

AGENT GENERATED

@toolittlecakes
toolittlecakes force-pushed the feat/trusted-account-origins-v2 branch from 7ab21ac to c298a47 Compare November 22, 2026 14:07
@github-actions github-actions Bot closed this Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This is an automated message. We have closed this pull request because it has been open for more than two weeks.

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.

Allow configurable trusted self-hosted account/relay origins in production

1 participant