You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 31b3ba4
Browse filesBrowse the repository at this point in the historyBrowse files
feat(kernel): support credentials_provider on kernel connections (#1086)
* feat(kernel): support credentials_provider on kernel connections
On use_kernel=True the connector now builds the same provider chain as
Thrift (TokenFederationProvider wrapping ExternalAuthProvider) and passes
it to the kernel's external auth as a per-request header provider, so
header caching, token federation with identity_federation_client_id and
exchange fallback behave as on Thrift. credentials_provider takes
precedence over access_token and every auth_type (azure-sp-m2m included),
as on Thrift; paired with oauth_client_secret or oauth_jwt_key_file it is
rejected as ambiguous before any flow is chosen. The connector keeps its
HTTP client for these connections so the federation exchange works, and
an older kernel wheel without header_provider raises NotSupportedError.
KERNEL_REV pins the kernel commit that adds the header provider.
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
* test(kernel): assert the credentials_provider guard by its own message
The old-kernel test's fake Session lacked enable_geospatial_support, so
the geospatial guard raised a NotSupportedError with the same
"newer databricks-sql-kernel" text before the header_provider guard
could be checked. Removing the header_provider guard left the test
passing. Add the kwarg to the fake and match on the
"credentials_provider requires a newer databricks-sql-kernel" message.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
* test(kernel): make header_provider serialization test deterministic
Replace the sleep-based overlap test with the event-based version from
review: the first add_headers call blocks on a release event, so the
second call provably cannot enter while the first is in flight — the
test now fails deterministically without the serialization lock
instead of only almost-always.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
* test(kernel): cover the credentials_provider http-client gate
Add test_kernel_credentials_provider_keeps_python_http_client: on
use_kernel=True with a credentials_provider the connector still builds
a UnifiedHttpClient and hands it to the session, the federation-
wrapped provider chain and the kernel, as on Thrift. Verified the test
fails with the gate removed (TokenFederationProvider raises on
http_client=None). The no-provider control case is covered by
test_kernel_http_client_lifecycle[explicit].
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
* Pin the kernel to merged #527 (6d6c1e4)
KERNEL_REV moves from the #527 branch head 159a2ff to the commit
merged into kernel main, 6d6c1e4. That picks up the external-auth
conflict guard (Session rejects credential/OAuth/JWT/Azure/
federation/token-cache kwargs alongside auth_type="external"),
async-only external auth in the kernel core, reserved SEA
per-request routing headers, and the Volume and LZ4 config changes
that landed on kernel main in between. The connector passes only
auth_type="external" plus header_provider on the provider path, so
no connector change is needed.
Verified against the wheel built from 6d6c1e4: the full unit suite
(1465 passed), the real-kernel session (5) and async-reader (6)
suites, black and mypy.
Also drops the kernel-release sentence from the changelog entry; the
kernel floor and lockfile move at the joint kernel and driver
release, not here.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
---------
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Release History
2
2
3
3
# Unreleased
4
+
- Support `credentials_provider` on kernel connections (`use_kernel=True`), with the same header refresh and token federation as Thrift.
4
5
- Honor `_port` and `_connection_uri` on kernel connections (`use_kernel=True`), as Thrift does. Requires a databricks-sql-kernel release that includes databricks/databricks-sql-kernel#505.
5
6
- Speed up `fetchone()`, `fetchmany()` and `fetchall()` by building each result `Row` with fewer Python calls. The rows are unchanged. Large results and many concurrent cursors in one process benefit most.
|`token_url` (OAuth M2M) |`str`| ❌ | ✅ |`None` ⇒ OIDC discovery |**Kernel-only.** OAuth IdP token endpoint override. Required for JWT M2M against an external-IdP-backed workspace (e.g. Entra ID for Azure Databricks), since Databricks-native OIDC does not advertise the `private_key_jwt` method. Applies to shared-secret M2M too. |
95
95
|`oauth_scopes`|`List[str]`| ❌ | ✅ |`["sql","offline_access"]` for U2M |**Thrift ignores custom scopes** — it always uses the built-in scope set. Kernel honors custom scopes for U2M and M2M; an omitted M2M value uses the kernel's own default. |
96
-
|`credentials_provider`|`CredentialsProvider`| ✅ |❌|`None`| Custom external credentials provider. **Rejected on the kernel path** (`NotSupportedError`) — it is an opaque token source, so the kernel cannot own the token lifecycle; use `oauth_client_id` +`oauth_client_secret`for M2M, or the Thrift backend. |
96
+
|`credentials_provider`|`CredentialsProvider`| ✅ |✅|`None`| Custom external credentials provider. Takes precedence over `access_token` and `auth_type` on both backends. On Kernel the connector's provider chain (header caching, token federation with `identity_federation_client_id`, exchange fallback) runs as on Thrift and supplies the headers for every kernel request; combining it with`oauth_client_secret` or `oauth_jwt_key_file` raises `NotSupportedError`. |
97
97
|`identity_federation_client_id`|`str`| ✅ | ✅ |`None`| Workload identity / token-federation client id (kernel support added in #910). |
98
98
|`experimental_oauth_persistence`|`OAuthPersistence`| ✅ | ❌ |`None`|**Thrift-only.** The kernel owns its own token lifecycle and does not accept a persistence store. |
99
99
|`oauth_token_cache_enabled`|`bool \| None`| ❌ | ✅ |`None`|**Kernel-only, U2M-only.** Controls whether the kernel persists OAuth U2M refresh tokens to disk (AES-256 encrypted, in the OS config dir — `~/Library/Application Support/databricks-sql-kernel/oauth/` on macOS, `~/.config/databricks-sql-kernel/oauth/` on Linux; requires databricks-sql-kernel PR #283). **Disabled by default:** when unset (None) or False, the connector disables on-disk persistence (tokens in-memory only, matching Thrift); True enables the cache. Omitting it does **not** inherit the kernel's enabled-by-default. Distinct from `experimental_oauth_persistence` — this toggles the kernel's built-in encrypted storage, not a pluggable callback. |
0 commit comments