Skip to content

fix(console): Settings, Packages, Audit Log and the connector pages send the stored bearer token - #37077

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/issue-36981-setup-pages-bearer
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/issue-36981-setup-pages-bearer

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #36981

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:管理员只靠浏览器里保存的登录令牌在线(会话 Cookie 被同机第二个本地运行时替换、被拦截或被清掉)时,设置、已安装应用、审计日志、连接器凭据和连接器连接这几页从报"需要登录"变为正常加载;只用 Cookie 登录的管理员看不到任何变化。
  • 为什么做:控制台其它页面都会带上登录令牌,只有这几张设置页漏带,属于"控制台设置页"这一块的体验缺陷,替所有遇到这种登录状态的管理员解决。
  • 出错会怎样:最坏情况是这几页重新读不到数据,与修复前一样显示加载失败;不改服务端接受什么、不改登录方式,可以直接撤回本次改动。
  • 要你做什么:无。

What changes

These Setup surfaces called their endpoints with the session cookie only, so a session held by its bearer token alone (the case the card measures) read a 401 there while the rest of the console worked. Each now goes through createAuthenticatedFetch from @object-ui/auth, the path every other console request already takes. credentials: 'include' is still passed on every call, so the cookie rides along exactly as before. A 401 now reaches the console's session-ended check, as it does on every other page. Besides the bearer, the shared wrapper also stamps X-Tenant-ID (the active organization) and Accept-Language (from the html lang attribute, never overriding a header the caller set) on these calls, and stores a rotated set-auth-token from the response, exactly as it already does for every other console request (L1 N1). Nothing changes in what the server accepts, how sessions are minted, stored or refreshed, cookies, CORS or any policy.

Surface (card row) Calls routed through the authenticated fetch
All settings and every namespace page the five /api/settings calls in pages/settings/api.ts (list, read, save, action, and the judged client-address read of the Authentication and Access policy pages)
Installed apps (Packages) PackagesPage's apiJson (every /api/v1/packages call the page makes); in marketplaceApi.ts, the runtime's own /api/v1/cloud-connection/installed and org-packages reads and every /api/v1/marketplace/install-local* call
Audit log the /api/v1/data/sys_audit_log read
Connector credentials the three credential-ref calls in connectorCredentials.ts
Connector connections the one call helper in connectorConnections.ts (declaration, registry, status, begin, revoke)

Each module builds the wrapper per call (createAuthenticatedFetch()(input, init), as approvalsApi.ts does). A module-level instance would run at import, before a test file's hoisted @object-ui/auth mock can supply it.

Audit log failure state: a failed read no longer draws the "No audit entries" empty state, because the table card is not drawn under the alert. The alert shows the refusal's own sentence when the response carries the declared envelope (readEnvelopeFailureText). Otherwise it shows the page's own "Failed to load audit log". It never shows the raw response body or a bare machine code.

marketplaceApi.ts: the calls to the cloud control plane's own origin (getCloudBase()) and the marketplace browse calls (credentials: 'omit') are deliberately left alone. The cloud origin must never see this runtime's bearer.

Tests

New pins, each with a cookie-only control (no token stored: no Authorization header, credentials: 'include'):

  • ui/apps/console/src/pages/settings/api.bearer.test.ts: every settings call sends Authorization: Bearer TOKEN when a token is stored.
  • ui/apps/console/src/pages/system/AuditLogPage.bearerAndFailure.test.tsx: the ledger lists against a server that answers only the bearer. A 401 (the REST seam's flat body) shows "Failed to load audit log", with no HTTP 401, no JSON and no UNAUTHENTICATED, and does not show "No audit entries". An enveloped 403 shows its sentence. An empty answer still shows the empty state.
  • ui/packages/app-shell/src/views/setup/setupDoorsBearer.test.ts: every connector credential and connection call, and the org-packages, cloud-installed and install-ledger reads.
  • ui/packages/app-shell/src/views/metadata-admin/PackagesPage.bearerSession.test.tsx: the Installed Apps address lists a marketplace install against a server that refuses any request without the bearer.

Fixture triage: the authenticated fetch reads response.headers (for a rotated session token, which a real Response always carries). The Response doubles of 29 existing settings, connector and Packages test files carried only ok, status and json. Each gains headers: new Headers(). The display-locale harness (consoleFaces.displayLocale-9909.test.tsx) mocks createAuthenticatedFetch with a fixed empty answer, so its mock now hands a case that stubs the wire to that stub. No assertion changed.

Acceptance notes

  • Same defect family, not fixed here (reported for a family card): packages-io.ts's held package-list read (GET /api/v1/packages, read by the shell's sidebar, header and Studio entries on every page) is cookie-only too. In the browser it answered 401 on every Setup page with a bearer-only session. Fixing it moves the Response doubles of roughly a dozen unrelated shell test files, so it was left out of this card. Many other ui/ modules still call fetch with the cookie only.
  • actionErrorDetail (@object-ui/core) reads a bare-string error before message. Against the REST seam's flat 401 body ({ error: 'UNAUTHENTICATED', code, message }, a sanctioned envelope per anonymous-deny.ts), it therefore answers the code. That is where the connector connections page's bare UNAUTHENTICATED came from. With the bearer attached these surfaces no longer meet that 401, and a real ended session goes to the session-ended check. The shared reader is not changed here.
  • Browser cookie-only control: after sign-in, the console's session check writes the token back into localStorage from the cookie session, so a "cookie only, no token" state cannot be held in a real browser tab. The cookie-only control is therefore pinned at unit level. In the browser, the cookie session still loads every surface.

Verification

Reproduced on main, then fixed (real boot: showcase backend + Console dev server, signed in, session cookie removed, bearer kept)

On main (305fe60), every surface answered 401 without the bearer:

settings hub        401 GET /api/settings bearer=no            "Authentication is required to access this endpoint."
settings/company    401 GET /api/settings/company bearer=no
access_policy       401 GET /api/settings/access_policy, 401 GET /api/v1/auth/client-address
installed apps      401 GET /api/v1/packages, 401 GET /api/v1/marketplace/install-local   "... (UNAUTHENTICATED)"
audit log           401 GET /api/v1/data/sys_audit_log         "HTTP 401: {"error":"UNAUTHENTICATED",...}" + "No audit entries"
connector creds     401 GET /api/v1/automation/connectors/credential-refs
connector conns     401 GET /api/v1/meta/connector             "Could not load connector connections. UNAUTHENTICATED"

With the fix, in the same state, every request carried the bearer, answered 200, and the pages rendered their content (settings manifests and fields, the Packages list, audit rows, the connector empty states). No page showed HTTP 401, UNAUTHENTICATED or "Authentication is required".

Pins fail on main's source, pass on the fix; ablation

Against main's source (the seven source files restored to 305fe60e6e on disk, each blob checked equal to the base blob, then restored to HEAD, with git diff HEAD empty afterwards), the four new pin files failed exactly the bearer pins and the audit failure-state pins. The cookie-only controls and the empty-state control passed:

Test Files  4 failed (4)
     Tests  21 failed | 21 passed (42)

Ablations at 8d5bf768c5, through scripts/ablation-replace.mjs. Each mutation was proven on disk (anchor 1 to 0, blob moved). Each restore was proven (blob equal to HEAD, git diff HEAD empty).

settings api.ts     createAuthenticatedFetch()(input, init) -> fetch(input, init)   6 failed | 6 passed (12)   only the bearer cases
PackagesPage.tsx    same mutation                                                   1 failed | 1 passed (2)    the bearer-only listing
AuditLogPage.tsx    table-card guard -> always drawn                                2 failed | 3 passed (5)    both failure-state pins

An earlier ablation of connectorConnections.ts (module-level form) turned exactly its five bearer cases red: 5 failed | 18 passed (23).

Suites, typecheck and gates

Run at 7d8601826f (the final head): the eight edited or new test files that changed last, Test Files 8 passed (8), Tests 74 passed (74). @object-ui/app-shell type-check exit 0. At 8d5bf768c5: @object-ui/console type-check exit 0. Both typechecks ran after building the dependency closure (pnpm --filter '@object-ui/console^...' build, exit 0).

Full package suites were run at f8533fabdd. Only test files changed after it.

  • @object-ui/console: Test Files 1 failed | 331 passed (332), Tests 7 failed | 3560 passed (3567). All seven failures were in consoleFaces.displayLocale-9909.test.tsx, whose auth mock answered {} for the audit ledger. Its mock was fixed at fc22fa2f7d. The file then passed alone: 15 of 15.
  • @object-ui/app-shell: Test Files 1 failed | 2416 passed | 1 skipped (2418), Tests 1 failed | 22867 passed | 9 skipped (22877). The one failure (RecordDetailView.recordPageTiers-26678) is outside this diff's reach and passed alone, 10 of 10, at fc22fa2f7d. The full run took 6054 s on a shared box.

Derived gate families (node scripts/pm/dispatch-gates.mjs --commands): all 39 ran at 8d5bf768c5, each exit 0. That includes pnpm check:type-check-debt under the lock and pnpm --dir ui exec vitest run scripts/ (Test Files 172 passed | 2 skipped). --ran printed: "39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)". At that head check:test-source-alias was red on four edited test files. The fix (module-top side-effect imports) landed as 7d8601826f. At 7d8601826f, check:test-source-alias, check:undeclared-dep-imports and check:nul-bytes each exited 0.

node scripts/pm/overlap-check.mjs ran before each push from the third one on: VERDICT clean exit 0, and #36973 (which shares PackagesPage.tsx) merges cleanly.

Read first:

  1. ui/apps/console/src/pages/system/AuditLogPage.tsx: the failure and empty-state hunk. The table card is now conditional.
  2. ui/packages/app-shell/src/console/marketplace/marketplaceApi.ts: confirm only same-server calls moved to serverFetch, and that no getCloudBase() call did.
  3. ui/apps/console/src/pages/settings/api.ts: the five call sites.

Two-minute check: sign in on the Console, delete the better-auth.session_token cookie in devtools, and open Setup, then All Settings. The settings cards load. On main the page reads "Authentication is required to access this endpoint."


Generated by Claude Code

…ie-only requests

The settings client, the audit log read, the connector credential and
connection doors and the Packages reads are pinned to carry the stored
bearer token, with a cookie-only control, and the audit log failure
state is pinned apart from its empty state. These fail before the fix.

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
…thenticated fetch

Settings (every namespace and the judged-address read), the audit log,
the connector credential and connection doors, the Packages list and
held list reads, and the runtime's own install-ledger and
cloud-connection reads called fetch with the session cookie only, so a
session held by its bearer token alone read a 401 there while the rest
of the console worked. They now go through createAuthenticatedFetch,
the path every other console request takes, which keeps the cookie and
reports a 401 to the session-ended check.

A failed audit log read no longer draws the no-entries empty state, and
its alert shows the envelope's sentence or the page's own failure text
instead of the raw response body.

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
…package list read

A module-level createAuthenticatedFetch() runs at import, before a
test's hoisted auth mock can supply it, so each door now builds the
wrapper per call, as approvalsApi does. The session's held package list
read is left as it was: it serves the shell on every page, not these
Setup doors, and is reported for its own card. The Response doubles of
the affected page tests gain the headers member the authenticated
fetch reads.

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
…ders member

The authenticated fetch reads the response's headers for a rotated
session token, as a real Response always has them; the doubles of the
settings, connector and Packages page tests carried only ok, status and
json. The changeset no longer names the held package list read.

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
…rough its authenticated fetch mock

The audit log's ledger read now goes through createAuthenticatedFetch,
which this harness mocks with a fixed empty answer; a case that stubs
the wire is now answered by its stub.

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
…d Packages and connector page tests

check:test-source-alias judges the test files a change edits; these
four reach the lazily loaded formula and lint packages from a case, so
each loads them at module top, as the other Packages page tests do.

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8

席位核对 — ACCEPT · repo:objectstack#3 · head 7d86018 · 2026-11-24T19:19Z

L1 read of #37077 (card #36981, p1) at 7d8601826f877174ab5cacfe833eb3dd539ddfba. Clause-② no and Metadata-protocol none, both true: this is client transport only, with no server or published-surface change. NOT governed, 689 changed lines, no contract review owed. l1-face is clean.

The fence (read hardest): attach the existing token only. Every changed call site swaps fetch for createAuthenticatedFetch()(…) and keeps its own credentials: 'include', headers, cache and signal. The sites are the five /api/settings calls plus getJudgedClientAddress, the audit ledger read, the connector credential and connection doors, PackagesPage's apiJson, and marketplaceApi's same-server calls (cloud-connection/installed, org-packages, install-local*). The wrapper is the one every console adapter read already uses. It sets Authorization: Bearer only when a token is stored and the URL is an /api/ call, so with no token stored the request is cookie-only exactly as before, and controls pin that. No server, auth-policy or route code is in the diff. serverFetch in marketplaceApi is used only on SERVER_URL / API_BASE. Every getCloudBase() call (browse, cloud installations, environments, get-session against the control plane) stays plain fetch, so the cloud origin never sees this runtime's bearer, and the comment marks that line with ⛔.

Against the card. All five surfaces in the card's table are covered. Behind the bearer, a 401 now reaches sessionEndEvents as it does on every other console page, which is the card's second acceptable outcome. Audit Log: a failed read shows readEnvelopeFailureText(body) or the page's own "Failed to load audit log", never HTTP 401: {json}. The table, and with it the "No audit entries" empty state, is drawn only when error === null, or while loading, or when rows exist. setError(null) at load start keeps a reload honest. Pins: each surface sends the bearer, with cookie-only controls, a 401 alert, an envelope sentence, and an answered-empty control. 21 are red on main, with ablations. The 29 test files that only gain headers: new Headers() follow from the wrapper reading set-auth-token off the response, and no assertion changed.

Changeset. It names @object-ui/app-shell and @object-ui/console at patch, and each sentence holds.

Nits.

  • N1. The wrapper also does what it does for every console request: it stamps X-Tenant-ID and Accept-Language, stores a rotated set-auth-token, and emits auth-gate events on a 403. So /api/settings and the doors now see the UI language too. That is the shared path the card asked for, not new policy, but the body could name it in one line.
  • N2. The two class-a out-of-scope findings (the packages-io cookie-only family, and actionErrorDetail showing UNAUTHENTICATED) are with triage via the seat.
  • N3. The first two pushes went out before overlap-check. Every later push read clean, including against refactor(studio): every Studio address comes from one builder; no address changes #36973. That is a process slip only.

Mechanical. All-checks: 38 success · 13 expected skips · 0 failed · 0 pending. Floor checks are green, mergeable_state is clean, and Fixes #36981 delivers the card.

Every open finding is a nit. ACCEPT, ordinary queue landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufziG2t1d9cfRQJDrHkB

Landing: 2026-11-24T19:46Z · area ux-C · p1 · head 1bf3dbe84a1f4f435d43d3dba26e95b3421b0c6e

Probe Reading
L1 席位核对 ACCEPT 7141942840 at 7d8601826f877174ab5cacfe833eb3dd539ddfba; this head is that head plus a clean merge of origin/main 254e396a with no conflict and no hand resolution (dev note 7142373364); pins 74/74, console + app-shell type-check exit 0 at this head
L2 not owed: Clause-②: no, Metadata-protocol: none, no packages/spec/src/**, no governed path
Checks 40 success, 15 skipped, 0 failed on this head
mergeable_state clean
check-governed-merges NOT governed, 689 changed lines ≤ 3000; one PR on the card
landing-k K was 39 at the accepted head, so main was merged; now 1 first-parent commit behind main (< 15), no translations/ file in the PR

L1 N1 is answered in the PR body (one line on what the shared wrapper also stamps). State: ready + auto-merge (merge queue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants