Repository navigation
Prefer URL parameter credentials over the Authorization HTTP header - #108980
Conversation
When a request carries both credentials in the URL query parameters (`user`/`password`) and an HTTP `Authorization` header, the parameters now take precedence and the header is ignored, instead of the request being rejected with "not allowed to use Authorization HTTP header and authentication via parameters simultaneously" (`AUTHENTICATION_FAILED`). This is needed because once a browser has remembered HTTP Basic credentials for an origin, it attaches the `Authorization` header to every subsequent request to that origin automatically - including requests that the application cannot add or remove headers from, such as a form submission or a download navigation. The Web UI (`play.html`) authenticates by putting the user name and password into the URL query parameters, so such a request would otherwise carry both and be rejected. This made downloading a result from the Web UI fail with error 516 once Basic credentials had been remembered by the browser. The `Authorization: never` sentinel still suppresses the header for requests that can set headers (`fetch`/`XMLHttpRequest`); this change covers the requests that cannot. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [b34045e] Summary: ✅
AI ReviewSummaryThis PR changes HTTP authentication so URL Final VerdictStatus: ✅ Approve |
…nd fix the style check The previous change excluded URL query parameters from `has_http_credentials` so they take precedence over the `Authorization` header. But that also suppressed the header for the configured-credentials mixing check: a handler with its own `<user>` plus URL parameters plus an `Authorization` header was no longer rejected and instead authenticated as the configured user, contrary to the stated contract that the no-mixing rule is unchanged for config credentials. Introduce a separate `has_authorization_header` flag (the raw presence of a non-`never` `Authorization` header) and use it to keep rejecting the header when the handler has configured credentials, regardless of the query parameters. The query-parameter precedence still applies to the default authentication path. Also reword the comment to avoid the mixed-case `XMLHttpRequest` token, which the C++ abbreviation style check rejected. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ader `tests/integration/test_http_auth_config_credentials` covers a custom `http_handlers` rule with a configured `<user>`: a plain request and a request with URL parameters both authenticate as the configured user, while an `Authorization` header - with or without URL parameters - is still rejected as a mix of authentication methods. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
CI status on The sole failure is The failed job can be re-run once the parent CI run completes. AI Review is ✅ Approve on this head and there are no unresolved review threads. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 15/15 (100.00%) · Uncovered code |
|
Follow-up on the CI status: the Confirming the rest of the state: AI Review is ✅ Approve on this head, there are no unresolved review threads, and the branch is I independently re-reviewed the authentication logic in |
|
Re-triaged the sole non- The I re-ran the failed private workflow; it is now Everything else is unchanged and green: public CI is fully green (150 SUCCESS / 0 failure / 20 skipped), |
|
Update on
So the failure is fully explained by unrelated flakes, one of which is already fixed on private |
…prefer-url-params Prefer URL parameter credentials over the Authorization HTTP header
Cherry-pick of #120407 onto 26.3. This branch still has the std::istream HTTP client API, so body_secrets and requestCredentialSecrets go through its receiveResponse / assertResponseIsOk signatures, the masked LOG_TRACE goes into the WriteBufferFromHTTP constructor (no WriteBufferFromHTTPRequestSender), and the master-only cancellation exit in doWithRetries is not taken. StorageURL.cpp gets the maskURIPassword.h include. maskURIPassword.h has no maskURIUserinfo / findURIAuthority here, so maskURICredentials uses the userinfo regular expression and the schema cache table a local startsWithURIScheme check. 05212 drops the bearer-token reflection case: it relies on URL parameter credentials taking precedence over the Authorization header (#108980), which this branch does not have. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When an HTTP request carries credentials both in the URL query parameters (
user/password) and in an HTTPAuthorizationheader, the URL parameters now take precedence and the header is ignored, instead of the request being rejected with:Why. Once a browser has remembered HTTP Basic credentials for an origin, it attaches the
Authorizationheader to every subsequent request to that origin automatically — including requests that the application has no way to add or remove headers from, such as a form submission or a download navigation. The Web UI (play.html) authenticates by putting the user name and password into the URL query parameters, so such a request would carry both the remembered header and the parameters and be rejected. This is exactly why downloading a result from the Web UI failed with error 516 once the browser had remembered credentials.The existing
Authorization: neversentinel still suppresses the header for requests that can set headers (fetch/XMLHttpRequest, used everywhere else inplay.html); this change covers the requests that cannot. The no-mixing rule is unchanged for the other authentication methods (SSL certificate auth,X-ClickHouse-*headers, config credentials).A stateless test (
04490_http_auth_url_params_over_header) sends a bogusAuthorizationheader together with correct URL-parameter credentials and asserts the query runs as the parameter user.Closes: #108974
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
HTTP interface: when credentials are provided both via URL parameters (
user/password) and anAuthorizationheader, the URL parameters now take precedence instead of the request being rejected. This fixes downloading results from the Web UI (play.html) failing withAUTHENTICATION_FAILED(error 516) when the browser has remembered Basic credentials.Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.7.1.408(included in26.7and later)