Skip to content

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

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

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

Conversation

@toolittlecakes

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

VITEST_MAX_WORKERS=2 pnpm exec turbo run test typecheck \
  --filter=@bb/connect-client \
  --filter=bb-plugin-bb-account \
  --filter=bb-plugin-connect \
  --filter=bb-app \
  --concurrency=2

All four package suites passed: connect-client 28, bb-account 110, Connect 158 and bb-app 216 (512 tests), with all four typechecks and required Turbo tasks (14 successful tasks). Changed TypeScript files passed oxlint; all 18 changed files passed oxfmt 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.

A bounded allow-all policy mutation made all 12 targeted denial tests fail across those four entry paths, despite the test egress guard. The original source was byte-for-byte restored before the passing checks. Synthetic HTTPS names are mapped to deterministic loopback HTTP in test transport; public TLS/self-host/native E2E was not performed.

Fixes #5744

AGENT GENERATED

@toolittlecakes

Copy link
Copy Markdown
Contributor Author

The only failed check, Windows server-2, timed out downloading frp from GitHub (UND_ERR_CONNECT_TIMEOUT); could a maintainer rerun it?

@quentin23soleil

Copy link
Copy Markdown

@ymichael wdyt about this contribution? It's something i'd be interested in for bb

@github-actions github-actions Bot closed this Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

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.

ymichael added a commit that referenced this pull request Nov 9, 2026
## Human comments

## What was wrong

The nightly stale-PR cleanup (`.github/workflows/close-stale-prs.yml`)
measured age from `created_at` only. A PR reopened after its first
closure was therefore closed again at the next scheduled run. #6215 was
created Oct 24, closed Oct 27, reopened Nov 7, and closed by the bot on
Nov 8 with "open for more than two weeks" after less than a day open.

## What changed

Before closing a candidate, the job reads the PR's issue events and
treats the PR as open since its latest `reopened` event (or `created_at`
if never reopened). PRs reopened within the fourteen-day window are
skipped and logged as "Recently reopened". The creation-date prefilter
is unchanged, so events are fetched only for PRs older than fourteen
days.

## How you verified

- Ran the embedded script's `open_since` against live data: #6215
resolves to its 2026-11-07T19:42:06Z reopen (so the Nov 8 run would have
skipped it); #6307 (never reopened, closed today) still resolves to its
creation time.
- Preview run (`APPLY=false`) of the full script against `get-bb/bb`
completes without errors.
- Checked the last five cleanup runs: #6215 is the only reopened PR that
was closed.
- `pnpm exec oxfmt .github/workflows/close-stale-prs.yml --check`, `git
diff --check`

> AGENT GENERATED

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
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

2 participants