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: 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:
|
Brings in SOCKS proxy support (#518). Conflicts were in NEXT_CHANGELOG.md, the http.rs test-module list and the C smoke test's call list; both sides are kept. The new tests/proxy_credential_logging.rs builds ProxyConfig with a struct literal, so it gets `..ProxyConfig::default()` for the new `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: 1 High · 2 Low
Looks good, with 1 low concern. The Negotiate path is careful: it fails closed, handles redirects hop by hop, keeps one deadline across all hops, and reuses the TLS setup. Every kernel send I checked (execute, token requests, feature flags) now goes through send_once, so all of them get the 407 retry.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
With `proxy-negotiate`, Linux builds linked libgssapi_krb5.so.2, so a binary built with the feature (the OSS ODBC driver) failed to load on machines without MIT Kerberos, even for users who never use Kerberos. Linux and other non-Apple Unix now open libgssapi_krb5.so.2 with dlopen the first time a Negotiate token is needed and make the same GSSAPI calls cross-krb5 made. If the library is missing, Negotiate fails session open (Unauthenticated) with an install hint. macOS (GSS.framework) and Windows (SSPI) keep cross-krb5; their libraries ship with the OS. Linux builds no longer need the GSSAPI headers or libclang. 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 Low · 2 Nit
Looks good: 3 low-severity concerns. The Negotiate design is careful: it fails closed, sends the token only on the CONNECT, retries a 407 once per hop and is well tested against a stub proxy. The remaining concerns are about how long token creation can block and how a library-load failure is cached.
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 — The timeout around rebuild_negotiate_client only drops the JoinHandle, so a hung GSSAPI or callback token call keeps its blocking thread. Repeated hangs can pile up threads in the blocking pool. Document the deferred reclamation or bound the token call itself. (Found by Claude Opus 5.5 · confirmed by the judge)
- ⚪ Nit — The first dlopen failure is cached for the life of the process. A long-running host that installs libgssapi_krb5 afterwards keeps failing until it restarts. Cache only a successful load and retry dlopen on failure. (Found by Claude Opus 5.5 · confirmed by the judge)
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
src/client/http.rs:1298— The Azure tenant-discovery probe builds a Negotiate client but sends directly through reqwest, so its first CONNECT 407 immediately fails session open instead o
Judge's evidence:self.build_negotiate_client(redirect).await?
- The first token at session open, and the tenant-discovery probe's token, are created within the request timeout (read_timeout), like a token rebuilt after a 407; a hung GSSAPI or callback call fails with Timeout instead of stalling Session::open. The blocking thread is documented as kept until the call returns. - A 407 on the probe's fresh token is Unauthenticated, as in send_once, not a generic NetworkError. - A failed libgssapi_krb5.so.2 load is no longer cached, so installing MIT Kerberos takes effect without restarting the host. - Document that Linux and macOS send a raw Kerberos token (MIT and Heimdal acceptors accept it; a SPNEGO-only proxy does not) and Windows sends SPNEGO. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Review-body nits on 47f5869, both handled in 8d4ad39:
|
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 Medium · 1 Low
Solid, well-tested feature with 1 medium and 1 low concern, both in the Negotiate error paths. I checked that the auth, CloudFetch and feature-flag requests all go through send_once, so every one gets the 407 retry.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
- Session::open passes a Timeout from the first Negotiate token through, as it does Unauthenticated, instead of re-wrapping it as NetworkError. - send_once computes its deadline with checked_add, so an extreme request timeout (such as Duration::MAX) cannot overflow Instant. 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 · 1 Nit
Solid, well-tested change. I found 1 medium and 1 low concern: a semver break on the public client::http::ProxyConfig, and an outdated NOTICE attribution. I checked the fail-closed path, the per-hop 407 retry, the deadline handling, the dlopen safety and GIL release, and found no correctness bugs.
Other findings
- ⚪ Nit — The NOTICE text says cross-krb5 links MIT
libgssapi_krb5, but cross-krb5 is only a dependency on Windows and Apple, and Linux loads MIT GSSAPI at run time. Reword it to GSS.framework on macOS and SSPI on Windows, in both NOTICE files. (Found by Claude Opus 5.5 · confirmed by the judge)
cross-krb5 is a dependency only on macOS (GSS.framework) and Windows (SSPI); Linux loads MIT libgssapi_krb5.so.2 at run time. NOTICE and adbc/NOTICE stay identical. 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 Low
Looks good — no blocking issues found. Proxy-auth validation, per-hop 407 retry, redirect handling, GSSAPI dlopen FFI and binding wiring look sound and are well tested. The macOS/Windows cross-krb5 paths have no CI or test run yet.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Brings in Volume PUT, GET and REMOVE (74c5cad). Conflicts: - NEXT_CHANGELOG.md: both sides' Added and Changed entries are kept. - src/client/http.rs: main added a total-timeout argument to build_reqwest_client and this branch added the shared Negotiate TLS setup, so it takes both. The session, Negotiate rebuild and redirect-probe clients pass the request timeout as main does; Volume's storage_client passes no total deadline and no shared TLS. - src/session.rs: the Negotiate pre-check and main's storage retry are both kept. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
Volume PUT, GET and REMOVE use their own storage client, so they got one Negotiate token at build time, created on an async worker, and no retry when a replay-caching proxy answered a later tunnel's CONNECT with 407. - The storage client's token is created off the async workers within the request timeout, as at session open. - A proxy 407 rebuilds the storage client with a fresh token and resends the request once, recreating its headers and streaming body; later requests use the rebuilt client. A second 407 fails closed as Unauthenticated, not retried, with the URL query left out of the message. - With Negotiate, a plain-HTTP storage URL is refused, as in send_once. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
From an independent review of the runtime GSSAPI loader: - The tenant-discovery probe uses one deadline for its token and its request, as send_once does, instead of up to twice the request timeout. - Token-creation timeouts are not retryable: a hung GSSAPI or callback call keeps its blocking thread, so automatic retries would pile them up. - Only Linux loads MIT GSSAPI at run time; other Unix (BSDs, illumos, Android) keep linking the system GSSAPI through cross-krb5, as before. - A NUL byte in the Kerberos service, host or realm is rejected with InvalidArgument instead of silently truncating the principal. - A hermetic test creates a real token from a synthesized credential cache in a child process, with no KDC. - The synchronous client constructors document that they create the first token on the caller's thread with no deadline. - PR checks run clippy and the unit tests with proxy-negotiate on Linux, and clippy with it on Windows. No KDC or fixture is needed. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
Brings in Volume options through the C ABI, ADBC, NAPI and PyO3 (d18b044) and configurable Arrow LZ4 compression (eb04529). The only conflict was pyo3/NEXT_CHANGELOG.md; both sides' Added entries are kept. 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 Low
Looks good: 2 low concerns. The fail-closed logic, the 407 retry on each hop, the redirect handling, the dlopen loader and the binding wiring all look correct and well tested. The two findings are a slower Volume rebuild path and gaps in non-Linux CI coverage.
Review incomplete
This review did not cover the whole change, so it is posted as a comment and does not approve the PR. Review the items below by hand, or split the PR so the bot can cover all of it:
- The PR diff exceeded the 200,000-byte review cap, so 13 generated/data hunk(s) were not shown to the reviewer (generated:
Cargo.lock); no production code was dropped.
negotiate_storage_first_and_fresh_tokens_time_out ran a normal transfer, whose fast first token had to fit a 100 ms budget that also covers building the storage client and scheduling the blocking call. A loaded CI runner went over it. The budget is now 1 s and the slow token takes 3 s, so the fast path has headroom and the slow one still clearly times out. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
Brings in custom credentials providers (AuthConfig::External, 6d6c1e4). The only conflict was NEXT_CHANGELOG.md; both Added entries are kept. 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 Low · 1 Nit
Looks good: 2 low concerns. The Negotiate design (fails closed, sends the token only on CONNECT, retries a 407 once per hop, bounds token creation by the request timeout) is consistent and well tested. Nit: in Python, passing proxy_negotiate_token without proxy_url raises a KernelError, while passing proxy_bypass_hosts alone raises ValueError.
Other findings
- ⚪ Nit — CI runs the proxy-negotiate tests only with
--libon Linux. Windows and macOS cross-krb5 paths get clippy only, and the integration tests never run with the feature. Add a feature-enabled test step on Windows and include--tests. (Found by Claude Opus 5.5 · confirmed by the judge)
Review incomplete
This review did not cover the whole change, so it is posted as a comment and does not approve the PR. Review the items below by hand, or split the PR so the bot can cover all of it:
- The PR diff exceeded the 200,000-byte review cap, so 14 generated/data hunk(s) were not shown to the reviewer (generated:
Cargo.lock); no production code was dropped.
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). Creating a token is bounded by the request timeout. It never falls back to Basic, a direct connection or another proxy.socks://URL, no proxy URL, a NUL in the target name) returnInvalidArgument.No new runtime dependency on Linux: with
proxy-negotiate, Linux loads MIT Kerberos (libgssapi_krb5.so.2) only when a Negotiate token is needed. A binary built with the feature, such as the OSS ODBC driver, still loads and works on machines without Kerberos; only Negotiate then fails, with an install hint. Other platforms usecross-krb50.5: GSS.framework on macOS, SSPI on Windows, the system GSSAPI on other Unix. The Python wheel does not enable the feature.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 (driver-test kernel suite, on the final code):
Also run:
cargo test --lib --tests, with and withoutproxy-negotiate: all pass. This includes the stub-proxy Negotiate tests (407 retry, replay cache, deadlines, Volume transfers through a replay-caching proxy), and a test that creates a real Kerberos token from a synthesized credential cache, with no KDC.cross-krb5path for the same credential cache.proxy-negotiatehas no Kerberos library dependency (readelf -d), and its live tokens came from the runtime-loaded library.proxy-negotiateon Linux, and clippy with it on Windows. No KDC is needed. Real tokens through squid are covered by the driver-test kernel nightly (databricks/databricks-driver-test#2422).Not run: live Kerberos on macOS or Windows. Both compile in the ODBC PR's CI.
Merge order
This pull request and its description were written by Isaac.