Repository navigation
feat(auth): custom credentials provider (AuthConfig::External) - #527
Conversation
Wire the reserved AuthConfig::External as a per-request header provider so host drivers can supply and refresh credentials through their existing provider APIs. - Kernel: TokenProvider gains headers() (default Authorization: Bearer <token()>), and HeaderProviderFn adapts a closure. The provider runs once per authenticated request, retries included, with no kernel cache, and is not wrapped by the kernel FederationProvider. The open-time preflight hands its headers to the first request, so it adds no extra call. Values with CR/LF/NUL fail the request; kernel-managed headers are ignored; provider errors fail fast as Unauthenticated. Auth headers replace same-named custom headers (case-insensitive) on SQL and feature-flag requests, as on Thrift. Request paths await the provider on the caller's runtime (AuthProvider::request_headers_async), so it can wait on that runtime's tasks even on a current-thread runtime. - pyo3: Session(auth_type="external", header_provider=callable). The GIL wait and the call run on tokio's blocking pool. A GC-tracked owner holds the callable, and every handle sharing the session links to it, so provider cycles through any handles are collected while a reachable handle keeps the provider. - napi: authMode External with an async headerProvider (second openSession argument) bridged through a weak ThreadsafeFunction, typed via ts_arg_type so the generated index.d.ts matches. - C ABI: kernel_session_config_set_auth_external with kernel_auth_headers_add / kernel_auth_headers_set_error; the callback runs on tokio's blocking pool, strings are copied into Rust-owned memory and user_data is released exactly once. - Tests: wiremock (Rust API and C ABI), C smoke test, pyo3 loopback tests. Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
Resolves the NEXT_CHANGELOG.md conflict with the SOCKS proxy entry (#518) by keeping both entries. 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 · 1 Nit
Looks good: 3 low concerns. The kernel, pyo3 and C ABI wiring is careful and well tested (primed preflight, blocking-pool callbacks, GC links, release semantics). The gaps are small: FFI panic containment, Accept-Encoding handling, and napi test coverage.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — The new extern "C" entry points are not wrapped in catch_ffi, so a panic would unwind through the host's C callback frame. The body only pushes to a Vec and copies strings, so the risk is small, and the other session setters don't use catch_ffi either. Wrap the body in catch_ffi for safety. (Found by Claude Opus 5.5 · confirmed by the judge)
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 overall: 1 medium and 3 low concerns. The kernel, C ABI and pyo3 paths are well tested and the GIL and runtime handling is careful; the napi bridge is the main gap in coverage.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit —
HeaderProviderFn::tokenstrips only the exact-caseBearerprefix, so a provider returningbearer xfailstoken()whileheaders()works. Match the scheme case-insensitively. (Found by Claude Opus 5.5 · confirmed by the judge)
aakash-saravanan-db
left a comment
There was a problem hiding this comment.
Approving. The External provider wiring, header validation, and callback lifetimes across PyO3, N-API and the C ABI look right to me. The inline comments are optional cleanups plus one coverage note.
One description fix: the Summary's line about a real GitHub OIDC federation exchange passing from the Python and Go drivers cites "driver-test AUTH-033 in CI". I couldn't find that run. AUTH-033 isn't on databricks-driver-test main yet, and databricks/databricks-driver-test#2423 has no CI checks at its current head. Could you link the run, or reword it to say the case is pending in #2423?
Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Thanks for the review. I added the Python, Go and Node.js AUTH-033 run links and their temporary-branch provenance to the description. In 672d14e, provider headers can no longer override SEA routing headers; External is async-only; the collision tests share their fixture; and the real napi binding has loopback resolve/reject and idle-exit coverage. My earlier claim that the Node driver unit test used a real binding was incorrect; it uses a fake binding. |
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, with 2 low concerns. The async-only External path, the header validation and replacement rules, and release of the C/Python callbacks are well designed and well tested at the unit, wiremock and binding tiers.
Other findings
- ⚪ Nit — The rustdoc on
kernel_session_config_set_auth_externallists only eight ignored kernel-managed headers. The C header,TokenProvider::headersandKERNEL_MANAGED_HEADERSalso ignore three per-request SEA routing headers. Add those three headers to the rustdoc. (Found by Claude Opus 5.5 · confirmed by the judge)
Signed-off-by: cat23123 <58714163+cat23123@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Thanks for the re-review. In dc6b454, Node external auth rejects conflicting credential options, and the C callback rustdoc now lists all three kernel-managed SEA routing headers. The Node driver’s External path does not forward those conflicting options. |
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 solid: 1 medium concern. External auth is wired consistently across Rust, PyO3, napi and the C ABI, with good wiremock, FFI and GC-cycle coverage; the one gap is that a hung host provider has no time limit.
Summary
Add
AuthConfig::Externalso Python, Node.js and Go applications can supply credentials and extra request headers through their existing providers. The kernel requests fresh headers for each authenticated request and leaves caching and token federation to the provider.What changes
Testing
The real GitHub OIDC federation AUTH-033 case passed in nightly workflows dispatched from a temporary driver-test branch carrying #2423 and a
driver_refinput: Python, Go, and Node.js. AUTH-033 itself lands in #2423.Local checks cover Rust, Python, Node and C bindings, including Node tests against the built native binding and a loopback server. One Rustls mTLS library test also fails on main on the test host. Windows and macOS were not run locally.
This pull request and its description were written by Isaac.