Repository navigation
Conversation
Authenticate to HTTP proxies with `Proxy-Authorization: Negotiate`
(Kerberos/SPNEGO) on the CONNECT, for parity with the Python connector's
`_proxy_auth_method="negotiate"` and Simba ODBC `ProxyAuthType=2`.
- `ProxyConfig::auth`: `ProxyAuth::Default` (unchanged Basic/none),
`ProxyAuth::Negotiate { service, host, realm }` (cross-krb5 0.5 behind
the non-default `proxy-negotiate` feature: system GSSAPI on Unix, SSPI
on Windows; ambient credentials, no delegation; target defaults to
`HTTP/<proxy host>`) and `ProxyAuth::NegotiateCallback` (caller tokens,
used by the Python binding, which links no GSSAPI library).
- A token is created at client build (session open) and once more when
the proxy answers a CONNECT with 407; only that hop is resent once on
the rebuilt client, which then serves new requests. A second 407 on
the same hop fails the request. It never falls back to Basic, a direct
connection or an env proxy. Every token (session open, the Azure
tenant redirect probe, 407 rebuilds) is created on the blocking pool,
never on an async worker.
- A Negotiate client loads its TLS setup once (native-tls: the
connector; rustls: the OS trust store) and every 407 rebuild reuses
it, so a rebuild only creates a client with the new token.
- With Negotiate the kernel follows redirects itself with reqwest's
default rules, so a 407 on a later hop never resends a request the
server already received. As in reqwest, one request timeout covers
every hop, the fresh-token rebuild and the final body. The retry
ladder, U2M OAuth token requests and the feature-flag GET all send
through `send_once`.
- A token failure fails session open with the GSS major/minor message
and no network I/O (`Unauthenticated`). Basic credentials, non-http(s)
proxy URLs or a missing URL with Negotiate are `InvalidArgument`;
`Negotiate` without the feature is rejected as unsupported.
- C ABI `kernel_session_config_set_proxy_negotiate`; pyo3 `proxy_url`,
`proxy_bypass_hosts` and `proxy_negotiate_token` kwargs.
- Tests: a stub CONNECT proxy with replay-cache semantics (default PR
tests, both TLS backends; tunnels, redirects, deadlines, U2M token
requests, TLS parity of rebuilt clients, slow tokens off the async
workers), a real MIT KDC + squid `negotiate_kerberos_auth` fixture
(`ci/proxy/negotiate`, new PR job for both TLS backends), C smoke and
pyo3 pytest cases.
Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
The job ran on every PR, push and merge-queue entry, and its real KDC + squid replay test depended on how many tunnels happened to overlap. Remove the job, ci/proxy/negotiate/{start,stop}.sh and the ignored KDC test. The stub-proxy Negotiate tests still run in the existing PR jobs on both TLS backends, and the driver-test kernel nightly covers real Kerberos tokens through squid.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com>
The replay test now holds each origin answer until a wave of six requests has all reached its tunnel, and the deadline test doubles its delays and timeouts. The slow-token test waits on an async signal instead of a 20 ms ticker racing a 500 ms block. Test-only change; proxy code is untouched. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium · 3 Low · 1 Nit
Looks solid: 4 low-severity findings and nothing blocking. Validation fails closed, the token is kept out of logs and errors, and the stub-proxy tests are thorough. One gap: the napi binding does not expose the new proxy auth, so the bindings now differ.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — After
kernel_session_config_set_proxy_negotiateis called, there is no way to clear it on a reused config, and passing all NULLs still selects Negotiate with the default target. Document that the setting is sticky, or add a clear path. (Found by Claude Opus 5.5 · confirmed by the judge)
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
src/client/http.rs:1209— The Negotiate redirect-probe branch sends directly through reqwest, so a CONNECT 407 immediately fails Azure tenant discovery instead of receiving the promised
Judge's evidence:self.build_negotiate_client(redirect).await?
- Make NegotiateTokenCallback's inner closure pub(crate); `new` stays the public constructor. - Pin the CONNECT-407 detection against a real tunnel error from the stub proxy, so a reqwest or hyper-util bump that rewords it fails a test. - Document why concurrent 407 rebuilds are not coalesced. - Document that kernel_session_config_set_proxy_negotiate stays on the config. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Medium · 3 Low
Looks reasonable: 1 medium and 2 low concerns. The napi binding (napi/src/database.rs:910) doesn't expose Negotiate. If that's intended, the PR or changelog should say so so the bindings don't drift apart.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
client::ProxyConfig is re-exported as stable surface for advanced wrappers, so code that builds it with a struct literal needs `..Default::default()` now that it has an `auth` field. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 4 Low
Looks solid, with 1 medium and 1 low concern. Fail-closed handling, the hop-by-hop 407 retry and the redaction are well tested. The napi binding still exposes no Negotiate option; either add one or document the difference.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
… list without a proxy - Fail closed when the Negotiate token callback runs after interpreter shutdown: use Python::try_attach and return an error instead of attaching during finalization. - Raise ValueError for proxy_bypass_hosts without proxy_url instead of silently dropping the bypass list, and document the requirement. - Document that a streaming (non-cloneable) body gets one plain attempt with no 407 retry and no redirect following; all current callers send cloneable JSON or empty bodies. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 High · 1 Low
Looks good, with one low concern. I checked every send path. OAuth, feature-flag and SEA traffic all go through send_once, so a proxy 407 gets its fresh-token retry. The C ABI, PyO3 and public-API changes are consistent with each other and documented.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
src/client/http.rs:1221— The Negotiate tenant-discovery client still sends directly through reqwest, so a CONNECT 407 immediately fails Azure session opening instead of receiving the pr
Judge's evidence:self.build_negotiate_client(redirect).await?
reqwest forwards a plain-HTTP request to the proxy with the Negotiate token attached and no tunnel, and a 407 there gets no fresh-token retry. With Negotiate, a plain-HTTP request now fails with InvalidArgument before any I/O, and a redirect to plain HTTP fails with NetworkError before that hop, so the token only ever rides on CONNECT. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
The second hop now has 1200 ms (redirect) and 800 ms (body) of slack before the deadline, and the deadline still lands at least 800 ms before the request could finish, so a per-hop timeout restart is still caught. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 3 Low
Looks solid: 2 low concerns. The token goes only on CONNECT, fails closed, and the 407 retry is scoped to the failing redirect hop, with thorough stub-proxy tests. The gaps are edge cases in the plain-HTTP guard.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
The Azure tenant-discovery probe sends through its own client, so it now applies the same https-only rule as send_once. The Negotiate docs also say the rule covers hosts on the bypass list. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Review-body findings that had no inline thread:
|
Summary
Adds Kerberos (
Negotiate) authentication for HTTP proxies, so connections work through corporate proxies that requireProxy-Authorization: Negotiateon theCONNECT. This is proxy authentication only, not warehouse Kerberos. It is opt-in: the new cargo featureproxy-negotiateis off by default, and existing proxy settings behave as before.The OSS ODBC driver (databricks/databricks-odbc#528) and the Python connector (databricks/databricks-sql-python#1085) build on this. The Node.js (napi) binding is unchanged and does not expose Negotiate yet; the Node.js driver is out of scope for this feature.
What changes
ProxyConfig::auth = ProxyAuth::Negotiate { service, host, realm }. The target defaults toHTTP/<proxy host>in the default realm.ProxyAuth::NegotiateCallbacklets a binding supply the tokens instead.kernel_session_config_set_proxy_negotiate(config, service, host, realm).Session(proxy_url=..., proxy_bypass_hosts=..., proxy_negotiate_token=<callable>).CONNECT. It is never sent to the warehouse or storage, and never logged.Unauthenticatedand the Kerberos reason (for exampleTicket expired). It never falls back to Basic, a direct connection or another proxy.socks://URL, no proxy URL) returnInvalidArgument.Dependency:
cross-krb50.5, only withproxy-negotiate. It uses the system GSSAPI library on Linux/macOS and SSPI on Windows. The Python wheel does not enable the feature and links no Kerberos library.Known limit: a proxy with a Kerberos replay cache (for example squid with MIT's replay cache) rejects the first token on each new connection after the first, so each one costs one extra round trip. reqwest 0.12 sends the same proxy header on every connection. The retry is cheap: the TLS setup is reused, so a rebuild takes about 0.3 ms.
Testing
Live, through a test Kerberos KDC and a squid proxy with the replay cache on:
¹ The first DBSQL timing run failed while the test machine was overloaded (load average about 40 on 32 cores). The rerun passed.
Also run:
cargo test --workspace: 1,388 passed. It includes the stub-proxy Negotiate tests, which the existing PR jobs run on both TLS backends.cargo test, 38pytest).readelf -d).Not run yet: Windows (SSPI) and macOS builds.
Merge order
ProxyConfig. Whichever lands second rebases.This pull request and its description were written by Isaac.