Repository navigation
Web UI: store credentials for the implicit default user - #118637
alexey-milovidov wants to merge 64 commits into
Conversation
`storeCredentials` in `play.html` passed the raw `user` field as the `PasswordCredential` id. An empty field (the server's `default` user, or a user embedded in the server URL's userinfo) made the constructor throw `TypeError: 'id' must not be empty` on every Run, so such logins were never offered to the browser's password manager. Use the effective user (`effectiveConnectionUser`, falling back to `default`) instead, and skip the call in browsers without `PasswordCredential` (Firefox). Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [e21aef7] Summary: ❌
AI ReviewSummaryThe change saves implicit Web UI logins under the server-reported account, guards unsupported credential APIs, and carries account stamps through results, history, shaping, and Download. Reviewed PR head Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Prevent the configured-handler export mismatch and cover it with a regression case. Fix or link a tracking issue for the deliberately deferred same-visit account-stamp limitation. |
Address review: saving the implicit login under `default` (or under the user embedded in the server URL's userinfo) was not safe on its own, because `postImpl` and the other request builders appended `&user=` for any non-empty `user` field. Once the password manager refilled the remembered name into the field, the request stopped being the implicit-auth request it was saved from and was forced to `user=default`, which can override the URL userinfo. Now every request URL of the page obtains its `user` parameter from the new `userUrlParam`, which omits the parameter when the field equals the user an empty field already authenticates as (`effectiveConnectionUser` with an empty field: `default` on a plain server URL, or the userinfo user). So a refilled remembered login builds exactly the request an empty field builds, and a field naming a different user still takes precedence as before. `effectiveConnectionUser` now returns `default` instead of an empty string when neither a field user nor a userinfo is given, so the history / database-panel identity gates treat a typed or autofilled `default` as the same connection as an empty field, and `storeCredentials` stores that never-empty name directly. Adds `test_play_credentials_store`, a Node harness (like `test_play_reconcile_startup`) that runs the real `storeCredentials`, `effectiveConnectionUser`, `userUrlParam`, `getServerStatus` and `buildCompletionUrl` extracted from the served page: it stores the login with an empty field, simulates the password manager refilling it, and requires the request URLs and the connection identity to be unchanged, for the implicit `default`, a URL userinfo, a percent-encoded userinfo, and an explicit `default` overriding a userinfo. A source-level scenario pins that no request builder appends `&user=` bypassing `userUrlParam`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…default` Address review: `authenticateUserByHTTP` substitutes `default_session_user` for an empty `user`, which is server configuration and not necessarily `default`. Hard-coding `default` made `storeCredentials` remember the wrong name and `userUrlParam` drop an explicit `default` as redundant, so the page could keep authenticating as another user while showing and storing `default`. Now `effectiveConnectionUser` keeps the fully implicit case empty (only the URL userinfo user is derivable locally), `userUrlParam` omits the `user` parameter only for the userinfo user, and `storeCredentials` asks the server for `currentUser` (via `getServerStatus`, sent without a `user` parameter) and saves the login under the reported name, storing nothing if the server cannot tell. The harness covers a non-`default` session user and an explicit `default` without userinfo. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=afd5a1aab0eee388ce3fcf8ffabbb5d762194818&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%201%2F8%29 ( |
|
Investigated all three.
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes4 object files changed (+42.13 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 units6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline. |
|
Both fixes are open now:
|
…ion, drop the URL userinfo contract `storeCredentials` asks the server for `currentUser` while the query of the Run may still be in flight. With a `session_id` in the connection URL the two requests contended for the same session, and the server rejects a concurrent request with `SESSION_IS_LOCKED`, so the user's query could fail. The probe now goes to the server URL without `session_id`, `session_check` and `session_timeout` (`serverAddressWithoutSession`); the other parameters are kept byte for byte. `fetch` refuses URLs with credentials, so a server URL with a userinfo (`http://alice@host:8123/`) cannot be used from the page at all. Treating the userinfo as an implicit-auth source in `userUrlParam` encoded an unsupported contract, so `userUrlParam` is removed and the request builders are back to sending the `user` field as before. No login is stored for such a URL. The harness's `fetch` stub now rejects credentialed URLs like the browser does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…implicit one `storeCredentials` remembers an implicit login under the server-reported `currentUser`, but the connection-identity gates (`resetConnectionScopedState`, `liveDivergedFromRun`, the `window.onpopstate` restore) still treated the empty `user` field and the refilled name as different connections, so an autofilled login could clear `selected_database` and mark a `run=1` entry as diverged. Remember the learned implicit user per server endpoint in `localStorage` (the refill happens on the next visit) and fold it into `effectiveConnectionUser`. The Back/Forward restore now compares the user by identity too, so it does not replace a refilled login and drop its password. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failures of |
|
All three have fixes in progress:
|
The identity of a stored connection with an empty user (a result snapshot, a history entry, the selected database) was re-derived from the current `implicit_users` cache in `localStorage`, so after the server's `default_session_user` changed, an old implicit entry could be reinterpreted as belonging to the newly learned name and keep its `database=` / `run=1`. Record the learned implicit user next to every stored connection when it is recorded (`implicitUserStamp`: `implicitUser` on result snapshots and connection snapshots, `connectionImplicitUser` on history entries), and compare stored connections with the live one through `sameConnectionUser`, which uses the stored stamp. An entry without a stamp matches only an implicit live user (fail closed). `effectiveConnectionUser` no longer consults the cache. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=0692bc494e5fb12d09a36331ee78b3068926594b&name_0=PR&name_1=Stress%20test%20%28amd_debug%29 ( |
|
The stack at 0692bc4 (from That is the site fixed by #127834: its #126142 covers the other embedded-client site, |
… probe in flight `learnImplicitUser` keyed its in-flight probes by `required` too, so the verification of `replayConnectionUser` sent a second identical probe while an optional one was in flight. With `max_concurrent_queries_for_user = 1` the server rejected it with `TOO_MANY_SIMULTANEOUS_QUERIES`, the verification failed and the Download named the account, which a proxy-authenticated server rejects. Required and optional callers now share the probe in flight. If the shared optional probe was skipped after an export, the required caller sends its own once the skipped one has settled. New harness scenario `proxy-authenticated-replay-joins-optional-probe`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`checkCredentials` called `getServerStatus` directly, so with `max_concurrent_queries_for_user = 1` a check sent while an implicit-user probe was in flight was rejected with `TOO_MANY_SIMULTANEOUS_QUERIES`, and valid credentials were shown as failed with the connection menu opened. Admit it through `admitRunQuery`, and add the `credentials-check-waits-for-probe` regression scenario. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`loadCompletions` sent the completion query directly with `fetch`, so with `max_concurrent_queries_for_user = 1` a load started while an implicit-user probe was in flight was rejected with `TOO_MANY_SIMULTANEOUS_QUERIES`, and the suggestions stayed unavailable until another focus retried it. Admit it through `admitRunQuery`, holding the admission until the response body is read, and add the `completions-wait-for-probe` regression scenario. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… during the account probe A switch between already materialized notebook cells while `learnImplicitUser` is pending keeps the tab, the query text and `tab.reqNum`, and with matching completed results it leaves `deferred_run_cancelled` false, so the deferred `run=1` auto-run executed with the other cell's parameter bindings. `runDeferredStartupQuery` now also requires an unchanged `activation_num` and active cell after the probe. The `run-link-delayed-probe` scenario covers the cell switch; it fails against the previous version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t a cached Basic login The Download of an implicit result with no password is a form submission, which cannot suppress the HTTP Basic credentials the browser may have cached for the origin, while the verification (`replayConnectionUser`) sends `Authorization: never`. With neither `user` nor `password` the server took the cached header, so the export could run as another account than the verified one. The export now carries an explicit empty `password` parameter, which the server prefers over the `Authorization` header, after verifying exactly that request (`implicitReplayAuthentication`). If the server authenticates it as another account, the recorded account is named; if the server rejects the parameters as mixed with a proxy or a certificate authentication (where a cached header is rejected too), the empty field is kept; any other failure refuses the export. Also add the Popover API to the fake DOM of `reconcile_harness.js`: `play.html` now closes the download menu with `hidePopover` after the master merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The verification of a passwordless Download (`implicitReplayAuthentication`) is a different probe request than the ones `learnImplicitUser` coalesces, and `admitImplicitUserProbe` only waited for runs, so with `max_concurrent_queries_for_user = 1` it could lose the slot to a probe in flight, get `TOO_MANY_SIMULTANEOUS_QUERIES`, and refuse the export. Probes now wait for the probe in flight as well. The new harness scenario `passwordless-download-waits-for-probe` runs the complete Download sequence against a one-slot transport. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=d813cbe368af46261214742cb2b1f26b487a60d0&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 ( |
|
This PR did not cause the The fix is already merged: #131363 on master, backported to 26.10 by #132081 and first released in |
|
🕵 Merged the latest |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=84f7135e474cfd8e4b3d224527d0ecf38e40c283&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20distributed%20plan%2C%20targeted%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.
Merged the latest |
| const account = resolvedImplicitUser(server_address, implicit_user); | ||
| if (!account) return ''; | ||
| if (!learnedImplicitUser(server_address)) await learnImplicitUser(server_address, password, /* required = */ true); | ||
| return account === learnedImplicitUser(server_address) ? '' : account; |
There was a problem hiding this comment.
[Blocker] Verify the requested account before exporting after an identity mismatch.
For a configured dynamic_query_handler with handler.user, adding user=<recorded account> does not select that account: authenticateUserByHTTP uses the configured AlwaysAllowCredentials and ignores the URL credentials (src/Server/HTTP/authenticateUserByHTTP.cpp:291-308). Restore a result stamped alice on a new visit after that handler has been changed to bob: the probe correctly reports bob, but this branch returns alice, and Download submits user=alice without verifying it. The export succeeds as bob despite being attached to the stored alice result. This does not require reconfiguration during the page visit. The mismatch branch in implicitReplayAuthentication makes the same assumption.
I reproduced the full Download handler submitting that form without an alert using the configured-user authentication behavior from the server code. Please refuse the export when the account differs, or verify that the exact request with the explicit username authenticates as the recorded account before submitting it. Cover configured handler credentials in the regression harness; its current transport assumes that a URL username always chooses the authenticated account.
AI review of a later commit does not approve the PR, see the AI Review comment.
|
Acknowledged. I'm investigating why |
|
The fix is in #133657 (test-only). I found no path that skips the spread: every finite next refresh time goes through |
The Web UI (
play.html) offers the login to the browser's password manager vianavigator.credentials.storeafter each Run. It passed the rawuserfield as thePasswordCredentialid. When the field is empty (the server'sdefault_session_user), the constructor throwsTypeError: Failed to construct 'PasswordCredential': 'id' must not be empty.on every Run, so such logins were never saved. Firefox has noPasswordCredentialat all, which raised aReferenceErrorthere on every Run.Now the call is skipped in browsers without the API, and with an empty
userfield the login is stored under the real name of the implicit user: the server is asked forcurrentUser(ingetServerStatus, with nouserparameter, so the page never assumesdefault). When the password manager refills that name on the next visit, it selects the same account explicitly. Nothing is stored if the server cannot tell. The probe is sent only after the Run has settled, so it does not compete with the Run's query for the user's query slots (max_concurrent_queries_for_user), and withoutsession_id/session_check/session_timeout, so it does not contend for the HTTP session lock (SESSION_IS_LOCKED) with a query of another tab. A passwordless login of an emptyuserfield is also recorded under the account's name, so a stale autofilled password of the refilled login is dropped (dropAutofilledStalePassword). A server URL with a userinfo (http://alice@host:8123/) cannot be used from the page, becausefetchrefuses URLs with credentials, so no login is stored for it.Tested by the new
test_play_credentials_storeintegration test: a Node harness (liketest_play_reconcile_startup) runs the real functions extracted from the served page against a fakePasswordCredentialand afetchstub that, like the browser, rejects credentialed URLs. It covers the implicitdefaultand a non-defaultdefault_session_userround trip, an explicit user, a probe outside of the session and after the Run, a refill after a passwordless login, and the cases where nothing is stored.Related: #118638
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Web UI: when the
userfield is empty, the browser's password manager is now offered the login under the name of the user the server authenticates, instead of the page failing with an exception.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/118637]