Repository navigation
Hand the connection to the built-in web UI pages over postMessage - #115067
alexey-milovidov wants to merge 94 commits into
Conversation
The built-in web UI pages take their connection from their own query string, which cannot carry a password: a URL ends up in browser history, referrer headers, server access logs and proxy logs. Only `/webterminal` could be handed credentials by the page embedding it, over `postMessage`. Every page now speaks the same exchange. It announces itself to the window that opened or embedded it with `clickhouse-hello`, and adopts the server URL, user and password from the `clickhouse-credentials` reply, redoing whatever it had already loaded with the previous connection: `/play` re-probes the credentials, `/docs` rebuilds its name cache and re-runs the displayed search, `/dashboard` and `/processors-profile` reload behind the load already in flight, `/schema` and `/jemalloc` reload, and `/binary` drops its cached tiles and redraws. `/play` uses it for the Documentation icon: a plain click opens `/docs` through `window.open`, so a handle on it remains and the whole connection can be handed over - the documentation search then runs against the same server as the same user, with no password in a URL. A middle or modifier click keeps the anchor's native new-tab path, which carries `?user=` only, because such a window has no link back to `/play`. The reply is accepted only from that one host window, and only from an exact origin: the page's own, `https://console.clickhouse.cloud`, `https://console.clickhouse-staging.com` or `https://clickhouse.com`. The credentials are replaced wholesale, so a message that names only a server cannot attach credentials it did not carry to it - they may have been filled in by the browser's password manager for this page's origin. `webterminal.html` gated its own exchange on a `*.clickhouse.cloud` domain suffix, which trusts every Cloud service endpoint, and a service endpoint serves content of its owner's choosing. It now uses the same exact list. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [25b2403] Summary: ✅
AI ReviewSummaryReviewed #115067 at Final VerdictStatus: ✅ Approve |
|
🕵 @groeneai, investigate the unrelated Fast test failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115067&sha=fe0e9f7e5f444133abd2aa94e5d54361240cb77b&name_0=PR&name_1=Fast%20test. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
It is not unrelated: this PR's own diff to
So the test reports intended new content as a failure. CIDB confirms it is deterministic and yours alone: 3 FAIL rows across The sibling page tests all survived the same allowlist addition because each greps a page-specific marker with
Suggested fix, matching the siblings: ${CLICKHOUSE_CURL} -sS ".../play" | grep -o -F -m1 '<title>ClickHouse Query</title>'Worth avoiding the cheaper variant: adding only This is the second sighting. The same test failed the same way on 2026-07-15, also from a PR editing I can open the test fix as a separate PR, or you can fold the one-line change into this one. |
Use the `/play` page title rather than a generic trusted-origin string, so the test verifies the intended response even when the allowlist mentions `clickhouse.com`. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115067&sha=5c06adab64a3b4c53079371f6648671de79a1cb3&name_0=PR&name_1=Fast%20test
|
🕵 Folded the suggested test correction into 10139fa: |
Consume the complete response after matching the unique `/play` title, so `curl` does not report a broken pipe. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115067&sha=51e1a559312f66e9919ff57b1b040f6c9519162d&name_0=PR&name_1=Fast%20test PR: #115067
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes5 object files changed (+147.70 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units9 translation units recompiled, 18 s compile time in total, 9 of them have a recent master baseline. |
…dover test `04502_http_static_compression` and `04504_http_static_compression_fallback` asserted that `clickhouse.com` occurs exactly once in the whole `/play` page, the same oracle defect that `01528_play` had: this change adds `https://clickhouse.com` to `TRUSTED_HOST_ORIGINS`, so the string now occurs twice and the tests report intended new content as a failure. Assert the unique `<title>ClickHouse Query</title>` marker with `-m1` instead, exactly as `01528_play` now does. Adding only `-m1` to the old pattern was avoided on purpose: it would pass on any body that merely contains the allowlist string. Also renumber the new test to `05026` - master has grown three unrelated `04907_` tests since it was written.
Matching with `grep -m1` closes the pipe before `curl` finished writing, so `curl` reported `Failure writing output to destination`, the same breakage `01528_play` hit in f530668. The title occurs exactly once in the page, so the match cap is unnecessary; drop it and let the response drain.
|
🕵 Pushed
Verified locally against a server built from this branch: The remaining AI-review Major ( |
The dashboard names in the selector (`dashboard_queries` and the `search-options` datalist) were loaded only by `start`, so after a handover from server A to server B they still described A: dashboards that exist only on B were submitted as SQL. Now `applyConnectionFromHost` reloads the list from the new server before reloading the dashboard, and `populateSearchOptions` drops the previous entries first. The selected dashboard is resolved to its search query with the previous list and shown again with the new one, so it stays selected if B has it too, and otherwise its query runs instead of its name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115067&sha=e47530e067b049ca274d2fe0b0cda28eeab6604f&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29 ( |
|
This is the Measured with
No separate PR from me. |
…om asset URLs `routingQueryOfRequest` compared the raw parameter names of the page's query string, so an encoded name such as `%70assword` or `pass%77ord` was copied into the URLs of the embedded JavaScript and CSS files, while the page itself (via `URLSearchParams`) recognizes it as `password`. Compare the names decoded the way the browser decodes them, keeping the original bytes of the retained routing parameters, and extend the asset regression test with encoded names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master ( The only red on |
|
🕵 Merged master ( |
Resolve the conflict in `WebUIRequestHandler.cpp` with the vendoring of the third-party assets on master: keep `replaceExternalAsset` (which also removes the `integrity` attribute of the CDN link), but pass it the relative URL made by `serverAssetURL`, so the links keep the path prefix and the routing parameters of a reverse proxy. The newly rewritten links in `/binary` (Leaflet) and `/jemalloc` (uPlot) use `serverAssetURL` as well, for consistency with the other pages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test added on master pins root-absolute `/js/...` links in `/binary`, `/jemalloc` and `/dashboard`. This PR intentionally makes these links relative to the page (`./js/...` for a top-level route), so that they keep the path prefix of a reverse proxy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master (
I tested this locally on a debug build. |
# Conflicts: # programs/server/binary.html
|
🕵 Merged master ( |
Master moved the documentation under `docs/concepts/features/connect-to-clickhouse/`; the new embedding page now lives at `built-in-web-interfaces/web-sql/embedding.mdx` next to the other Web SQL UI pages, with its links updated to the new paths.
The built-in web UI pages —
/play,/docs,/dashboard,/schema,/merges,/jemalloc,/processors-profile,/binary— take their connection from their own query string, which cannot carry a password: a URL ends up in browser history,Refererheaders, server access logs and proxy logs. Only/webterminalcould be handed credentials by the page embedding it, in apostMessagemessage.Every page now speaks that same exchange:
The page announces itself as soon as it can apply a connection, and the host answers. The page has to speak first because a host that opened it with
window.opencannot observe when a cross-origin document became ready, and an embedded page would otherwise race its host'sloadhandler.Having adopted a connection, each page redoes what it had already loaded with the previous one, so the handover also works when it arrives after the page started querying:
/playre-probes the credentials,/docsrebuilds its cross-link name cache and re-runs the displayed search,/dashboardand/processors-profilechain their reload behind the load already in flight (two concurrent loads would otherwise duplicate charts, or let a stale failure overwrite a good listing),/schemaand/jemallocreload, and/binarydrops its cached tiles and redraws.A handed-over server URL may carry a query string of its own — a default
database, or a proxy route that selects a cluster or a namespace, as inhttps://proxy.example/clickhouse/?cluster=a./playand/docsalready appended their request parameters to such an address with&;/binary,/dashboard,/merges,/schema,/jemallocand/processors-profilestarted a second?, which is not a separator — their first parameter was folded into the value of the last parameter of the endpoint, and the request went somewhere other than the connection just handed over. All of them now pick the separator the same way.Opening
/docsfrom/playThe Documentation icon in the
/playsidebar is the first user of the handover. A plain click opens/docsthroughwindow.open— the anchor'srel=noopenerwould sever the handle — and hands the whole connection over, so the documentation search runs against the same server as the same user without the password appearing in a URL. A middle or modifier click keeps the browser's native new-tab handling, which carries?user=only, since such a window has no link back to/play.Security
A reply is accepted only from the one window that opened or embeds the page, and only from an exact origin: the page's own,
https://console.clickhouse.cloud,https://console.clickhouse-staging.comorhttps://clickhouse.com. The list is exact rather than a domain suffix on purpose — every ClickHouse Cloud service endpoint is a*.clickhouse.cloudhost that serves content of its owner's choosing, and a trusted host can aim a page at a server of its own throughurl, which the user may then type credentials into believing it is still their own service.webterminal.htmlgated its own exchange on such a suffix and now uses the same exact list.urlis optional and defaults to the server the page already points at, but the credentials are replaced wholesale: a message that names only a server cannot attach credentials it did not carry to it, which is what keeps a password filled in by the browser's password manager for this page's origin from following aurlelsewhere. Outbound, credentials are always sent with an exact target origin, never'*'; the readiness announcement carries no secrets, only the fact that the page exists, which its host knows already.Verified in Chromium against a mock endpoint: the
/play→/docshandover, the handover into an iframe for all eight pages, rejection of a handover from an untrusted origin and from a same-origin window that is not the page's host, the wholesale credential replacement, and the exactness of the origin list for all nine pages (https://myserviceendpoint.clickhouse.cloud,https://evil.clickhouse.com,http://console.clickhouse.cloudandhttps://console.clickhouse.cloud.evil.comare all rejected). The committed test asserts that every served page implements both halves of the exchange, that its origin list stayed exact, and that it appends its request parameters to a query-bearing endpoint rather than starting a second query string./webterminalis covered by it too, with its ownwebterminal-hello/webterminal-credentialsmarkers: this change replaced itsendsWith('.clickhouse.cloud')trust with the same exact list, and the check rejects a bare host-name comparison as well, which would ignore the scheme. The protocol is documented indocs/concepts/features/interfaces/web-ui-embedding.mdx.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The built-in web UI pages (
/play,/docs,/dashboard,/schema,/merges,/jemalloc,/processors-profile,/binary) can now be handed their connection — server URL, user and password — in apostMessagemessage by the page that opened or embedded them, instead of taking it from their own query string, where a password would be recorded in browser history, referrer headers and access logs./playuses this when opening/docs, so the documentation search connects to the same server as the same user. A page accepts a connection only from the window that opened or embeds it, and only from an exact list of trusted origins.Workflow [PR]
Sync PR [sync-upstream/pr/115067]