Skip to content

feat(kernel): support custom credentials providers on the kernel backend - #656

Open
cathleeny wants to merge 1 commit into
mainfrom
cathleeny/ddf-custom-credential-provider-nodejs
Open

cathleeny wants to merge 1 commit into
mainfrom
cathleeny/ddf-custom-credential-provider-nodejs

Conversation

@cathleeny

@cathleeny cathleeny commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

authType: 'custom', 'token-provider' and 'external-token' now work on the kernel backend; until now, it rejected these modes. KernelBackend passes the client's own IAuthentication, the same chain DBSQLClient builds for Thrift, to the kernel, and the kernel calls it for the headers of every request.

What changes

  • Kernel External auth: the three modes map to the kernel's External auth mode. static-token, PAT, M2M and U2M are unchanged.
  • Call cadence:
    • custom calls authenticate() on every kernel request (Thrift does so on every RPC).
    • token-provider and external-token keep CachedTokenProvider, plus FederationProvider with enableTokenFederation. federationClientId, the exchange and the fallback on refusal are unchanged.
  • Header conversion: headers from authenticate() are converted the way node-fetch does on Thrift. Arrays and numbers become strings, and repeated names are joined with , .
  • Reyden auto-recovery: now works for these modes.
  • Kernel pin and typings: KERNEL_REV pins the kernel commit that adds the bridge. The typings add AuthMode.External and openSession(options, headerProvider?).
  • Docs: updated docs and one changelog entry.

Differences from Thrift on the kernel path:

  • A provider User-Agent is ignored.
  • undefined and null header values are skipped (Thrift sends the text).
  • An invalid token is refused with HTTP 403.

Known limit: a live successful token-federation exchange against a real federation policy was not tested, because the staging workspace has none. Exchange success is covered against a local mock /oidc/v1/token.

Testing

Live case (SELECT 1 on the kernel) DBSQL Reyden
custom provider ✅ 183 ms vs kernel PAT 186 ms ✅ 92 ms vs PAT 95 ms
token-provider (getToken() once per connection) ✅ 257 ms vs PAT 241 ms ✅ 91 ms vs PAT 91 ms
external-token + enableTokenFederation (exchange refused, falls back) ✅ 226 ms vs Thrift federated 228 ms ✅ 144 ms vs PAT 90 ms (one refused exchange per request, as on Thrift)
Invalid provider refused ✅ 403 ✅ 403

Unit and lint: these all pass.

  • 1,864 unit tests.
  • eslint, prettier and type-check.
  • 13/13 mock-server kernel cases: refresh, headers, errors, federation, concurrency, cancel and request counts.

Not run: Windows, macOS, and CI jobs that need a push.

Merge order

This pull request and its description were written by Isaac.

The kernel backend rejected `authType: 'custom'`, `'token-provider'` and
`'external-token'`, so applications that supply and refresh credentials
through a provider could only use Thrift.

These three modes now map to the kernel's `External` auth mode. KernelBackend
passes the client's own `IAuthentication` (the chain `DBSQLClient` already
builds for Thrift) as the napi `headerProvider`, and the kernel calls it for
the headers of every request, retries included:

- `custom` calls `provider.authenticate()` per request, as Thrift does per RPC.
- `token-provider` and `external-token` keep `CachedTokenProvider`, plus
  `FederationProvider` when `enableTokenFederation` is set, so caching,
  `federationClientId` and the exchange fallback match Thrift. The kernel's
  own federation does not wrap `External`.
- Provider headers reach the kernel with the values node-fetch sends on
  Thrift: every `HeadersInit` shape, array and non-string values stringified,
  repeated names combined. `undefined`/`null` values are skipped.
- A provider rejection fails the operation as `AuthenticationError` with the
  provider's message. A missing provider fails `connect()`.

`static-token`, PAT and OAuth mappings are unchanged.

KERNEL_REV pins the kernel commit that adds `External`, and
native/kernel/index.d.ts carries its `openSession(options, headerProvider)`
typing.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@cathleeny
cathleeny marked this pull request as ready for review December 3, 2026 00:51

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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 traced the provider from DBSQLClient.createAuthProvider through getAuthProvider to the kernel headerProvider: caching, federation and the missing-provider error all behave correctly. As the PR says, merging still depends on published native packages that include the bridge.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread CHANGELOG.md

## Unreleased

- Kernel backend: `authType: 'custom'`, `'token-provider'` and `'external-token'` now work, so applications can supply and refresh credentials through their providers, including `enableTokenFederation`. Requires `@databricks/databricks-sql-kernel-*` native packages from a release that adds custom credentials providers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — The changelog says a newer native release is needed but doesn't name the kernel change, unlike the neighbouring port entry, which cites databricks/databricks-sql-kernel#505. Add the kernel PR reference so the required package bump can be identified.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

)) as KernelConnection;
const nativeOpts = sessionOptions as unknown as Parameters<KernelNativeBinding['openSession']>[0];
nativeConnection = (await (headerProvider
? this.binding.openSession(nativeOpts, headerProvider)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High — The optionalDependency pins stay at 1.5.0, which reject authMode: 'External', so an npm install can't use the new modes until the packages are bumped. The changelog does flag this follow-up and the port entry did the same, so this is a release-ordering note, not a code bug. Bump the pins, lockfile and router once the kernel release is published.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

This branch was previously deployed

1 inactive deployment
azure-prod — e072b5ee Deployed Dec 2, 2026 by cathleeny via e2e-test (22.23.4, 22_23_4) #2279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant