Repository navigation
fix(console): Settings, Packages, Audit Log and the connector pages send the stored bearer token - #37077
Conversation
…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>
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>
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>
|
repo:objectstack#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8 席位核对 — ACCEPT · repo:objectstack#3 · head 7d86018 · 2026-11-24T19:19ZL1 read of #37077 (card #36981, p1) at The fence (read hardest): attach the existing token only. Every changed call site swaps Against the card. All five surfaces in the card's table are covered. Behind the bearer, a Changeset. It names Nits.
Mechanical. All-checks: 38 success · 13 expected skips · 0 failed · 0 pending. Floor checks are green, Every open finding is a nit. ACCEPT, ordinary queue landing. |
Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#3 · os-support-ai · session_01WGufziG2t1d9cfRQJDrHkB Landing: 2026-11-24T19:46Z · area ux-C · p1 · head
L1 N1 is answered in the PR body (one line on what the shared wrapper also stamps). State: ready + auto-merge (merge queue). |
Requested by Yibo Wang · project thread
Fixes #36981
Clause-②: no
Metadata-protocol: none
维护者速读
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
createAuthenticatedFetchfrom@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 stampsX-Tenant-ID(the active organization) andAccept-Language(from the htmllangattribute, never overriding a header the caller set) on these calls, and stores a rotatedset-auth-tokenfrom 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./api/settingscalls inpages/settings/api.ts(list, read, save, action, and the judged client-address read of the Authentication and Access policy pages)PackagesPage'sapiJson(every/api/v1/packagescall the page makes); inmarketplaceApi.ts, the runtime's own/api/v1/cloud-connection/installedandorg-packagesreads and every/api/v1/marketplace/install-local*call/api/v1/data/sys_audit_logreadconnectorCredentials.tscallhelper inconnectorConnections.ts(declaration, registry, status, begin, revoke)Each module builds the wrapper per call (
createAuthenticatedFetch()(input, init), asapprovalsApi.tsdoes). A module-level instance would run at import, before a test file's hoisted@object-ui/authmock 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
Authorizationheader,credentials: 'include'):ui/apps/console/src/pages/settings/api.bearer.test.ts: every settings call sendsAuthorization: Bearer TOKENwhen 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 noHTTP 401, no JSON and noUNAUTHENTICATED, 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 realResponsealways carries). TheResponsedoubles of 29 existing settings, connector and Packages test files carried onlyok,statusandjson. Each gainsheaders: new Headers(). The display-locale harness (consoleFaces.displayLocale-9909.test.tsx) mockscreateAuthenticatedFetchwith a fixed empty answer, so its mock now hands a case that stubs the wire to that stub. No assertion changed.Acceptance notes
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 theResponsedoubles of roughly a dozen unrelated shell test files, so it was left out of this card. Many otherui/modules still callfetchwith the cookie only.actionErrorDetail(@object-ui/core) reads a bare-stringerrorbeforemessage. Against the REST seam's flat 401 body ({ error: 'UNAUTHENTICATED', code, message }, a sanctioned envelope peranonymous-deny.ts), it therefore answers the code. That is where the connector connections page's bareUNAUTHENTICATEDcame 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.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: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,UNAUTHENTICATEDor "Authentication is required".Pins fail on main's source, pass on the fix; ablation
Against main's source (the seven source files restored to
305fe60e6eon disk, each blob checked equal to the base blob, then restored toHEAD, withgit diff HEADempty 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:Ablations at
8d5bf768c5, throughscripts/ablation-replace.mjs. Each mutation was proven on disk (anchor 1 to 0, blob moved). Each restore was proven (blob equal toHEAD,git diff HEADempty).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-shelltype-checkexit 0. At8d5bf768c5:@object-ui/consoletype-checkexit 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 inconsoleFaces.displayLocale-9909.test.tsx, whose auth mock answered{}for the audit ledger. Its mock was fixed atfc22fa2f7d. 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, atfc22fa2f7d. The full run took 6054 s on a shared box.Derived gate families (
node scripts/pm/dispatch-gates.mjs --commands): all 39 ran at8d5bf768c5, each exit 0. That includespnpm check:type-check-debtunder the lock andpnpm --dir ui exec vitest run scripts/(Test Files 172 passed | 2 skipped).--ranprinted: "39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)". At that headcheck:test-source-aliaswas red on four edited test files. The fix (module-top side-effect imports) landed as7d8601826f. At7d8601826f,check:test-source-alias,check:undeclared-dep-importsandcheck:nul-byteseach exited 0.node scripts/pm/overlap-check.mjsran before each push from the third one on:VERDICT clean exit 0, and #36973 (which sharesPackagesPage.tsx) merges cleanly.Read first:
ui/apps/console/src/pages/system/AuditLogPage.tsx: the failure and empty-state hunk. The table card is now conditional.ui/packages/app-shell/src/console/marketplace/marketplaceApi.ts: confirm only same-server calls moved toserverFetch, and that nogetCloudBase()call did.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_tokencookie in devtools, and open Setup, then All Settings. The settings cards load. Onmainthe page reads "Authentication is required to access this endpoint."Generated by Claude Code