Repository navigation
feat(auth): default U2M OAuth app to databricks-sql-connector - #247
Conversation
Consolidate the U2M default OAuth-app bundle in kernel core to
databricks-sql-connector / sql offline_access / port 8030 (was
databricks-cli / all-apis offline_access / 8020), so the kernel owns one
default and bindings stop encoding per-consumer identity:
- kernel core (session.rs): extract resolve_u2m_bundle() + constants; the
{client_id, scopes, redirect_port} default together as one coupled
bundle. u2m.rs DEFAULT_CALLBACK_PORT and c_abi/callback docs updated.
- napi: remove the databricks-sql-connector override so Node (and Go via
the C ABI) ride the kernel default; keep the empty-client_id guard.
- pyo3: keep the databricks-sql-python override and additionally pin its
registered redirect port (8020) so it does not inherit the new kernel
default 8030 and hit redirect_uri_mismatch.
pyo3/src/session.rs carries an unrelated cargo fmt line-wrap.
See PECOBLR-4039.
Co-authored-by: Isaac
Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Medium · 2 Low
Solid change — the coupled-bundle refactor in src/session.rs is clean, and the pyo3 port-pinning + napi delegation are correct and well-tested. The only concerns are stale doc/contract comments that still advertise the pre-PR defaults (databricks-cli / port 8020 / all-apis) after the behavior changed to databricks-sql-connector / 8030 / sql offline_access. These are consumer-facing surfaces the PR touched adjacent to but didn't update.
Other findings
- 🟡 Medium — The hand-written C ABI header still documents the pre-PR U2M defaults, but this is the actual contract Go/ODBC consumers link against. The PR updated the matching Rust-side docs in
src/c_abi/session.rs(databricks-cli→databricks-sql-connector, 8020→8030, all-apis→sql) but left this header saying:
* All args optional: `client_id` NULL → public `databricks-cli` client;
* `redirect_port` 0 → kernel default (8020); `scopes` (comma-separated)
* NULL → kernel default (`all-apis`,`offline_access`; ...
The kernel now fills databricks-sql-connector / port 8030 / sql offline_access (see resolve_u2m_bundle in src/session.rs and DEFAULT_CALLBACK_PORT = 8030 in src/auth/oauth/u2m.rs). A C-ABI consumer reading this header would be misinformed about the effective defaults. Update the kernel_session_config_set_auth_u2m doc block to match src/c_abi/session.rs.
-
🔵 Low — The kernel's public
AuthConfigdoc comments still describe the old U2M defaults and are now inconsistent with the code this PR changed: -
L291-294: "OAuth scopes default to
[\"all-apis\", \"offline_access\"]for U2M", "U2Mredirect_portdefaults to8020", "U2Mclient_iddefaults to\"databricks-cli\"". -
L320-326: field docs
None → "databricks-cli",... 8020,None → ["all-apis", "offline_access"]. -
L405-406: "the kernel fills
databricks-cli/ port 8020 / default scopes".
Actual resolved defaults are now databricks-sql-connector / 8030 / sql offline_access (resolve_u2m_bundle, src/session.rs). Since this is the public Rust API surface, the docs should be updated to match.
There was a problem hiding this comment.
The comment are wrong, it is no longer databricks-cli
There was a problem hiding this comment.
Fixed the stale databricks-cli references — the reviewer was correct that the kernel's default U2M client is now databricks-sql-connector. All six occurrences updated, comment-only, build and fmt clean.
Pushed b9fe214 (bundled with 1 other thread(s)).
Addresses: - #3777134872 at napi/src/database.rs:155 - #3778227002 at pyo3/src/auth.rs:83 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 2 Medium · 1 Low
Looks good functionally — the default-bundle refactor, the coupled resolve_u2m_bundle extraction, and the pyo3 port-pinning are correct and well-tested. The only concerns are stale documentation of the old databricks-cli / 8020 / all-apis defaults left behind on public surfaces the PR didn't update: the core src/config.rs rustdoc and the hand-written C ABI header (both medium), plus a legacy comment in src/auth/config.rs (low).
Other findings
-
🟡 Medium — The public v0
AuthConfigrustdoc still documents the old U2M defaults after this PR flipped the kernel bundle. Direct Rust consumers read these docs, so they now contradict the actual behavior inresolve_u2m_bundle(databricks-sql-connector/8030/["sql", "offline_access"]): -
L292:
U2M scopes default to `["all-apis", "offline_access"]`→ should be["sql", "offline_access"]. -
L293:
U2M `redirect_port` defaults to `8020`→ should be8030. -
L294:
U2M `client_id` defaults to `"databricks-cli"`→ should be"databricks-sql-connector". -
L324/326: the per-field
OAuthU2Mdocs (client_id→"databricks-cli",scopes→["all-apis", "offline_access"]) are stale in the same way. -
L405-406:
the kernel fills `databricks-cli` / port 8020 / default scopesis also stale.
The PR updated the napi/pyo3/c_abi source docs but missed the core public src/config.rs surface. Please update these to match the new bundle.
- 🟡 Medium — The hand-written C ABI header — the surface Go/ODBC consumers link against and read — still documents the pre-PR U2M defaults for
kernel_session_config_set_auth_u2m:
* All args optional: `client_id` NULL → public `databricks-cli` client;
* `redirect_port` 0 → kernel default (8020); `scopes` (comma-separated)
* NULL → kernel default (`all-apis`,`offline_access`; ...
The PR updated the mirroring rustdoc in src/c_abi/session.rs (to databricks-sql-connector / 8030 / sql offline_access) but not this header, which the PR description claims was updated. Since the header is hand-maintained (no cbindgen), it must be edited in lockstep — Go rides the kernel default and now hits 8030, so the header misdocuments the actual redirect port and client identity.
- 🔵 Low — The
AuthType::OAuthU2mbranch comment in this (legacy ADBC)AuthConfig::validatestill lists the old defaults:
// - client_id defaults to "databricks-cli"
// - scopes defaults to "all-apis offline_access"
// - redirect_port defaults to 8020
These three lines are now stale versus the new kernel bundle (databricks-sql-connector / sql offline_access / 8030). Lower priority than the public src/config.rs / C-ABI docs since this appears to be legacy config plumbing, but worth updating for consistency while touching the U2M defaults.
…r/8030/sql Address review doc-drift on #247: public surfaces still advertised the pre-PR U2M defaults (databricks-cli / 8020 / all-apis) after the behavior changed. Update the public AuthConfig rustdoc + oauth_u2m constructor doc (src/config.rs), the hand-written C ABI header (include/databricks_kernel.h), the c_abi unset-port sentinel comment, callback.rs default-port docs, and the legacy ADBC AuthConfig::validate comment (src/auth/config.rs). Also fix a contradiction the auto-fix left in pyo3/src/auth.rs: the PYSQL_OAUTH_SCOPES rationale claimed the kernel default was databricks-sql-connector + all-apis (that client uses sql). Reframe: pyo3 pins databricks-sql-python's sql scopes explicitly; they now match the kernel default but stay pinned so the bundle is self-consistent. Comment-only; build, clippy, fmt, and tests clean. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — a clean, consistent default-bundle swap (databricks-sql-connector / sql offline_access / 8030) with matching kernel, C ABI, napi, and pyo3 updates plus unit tests on all three crates. One low: the public AuthorizationCodeProvider::new() convenience constructor now pairs port 8030 with all-apis scopes, an incoherent bundle, though it's off the live session path.
Addresses: - #3778529395 at src/auth/oauth/u2m.rs:60 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
What
Consolidate the OAuth U2M default identity so the kernel owns a single default OAuth-app bundle and the language bindings stop encoding per-consumer identity. Because each OAuth app is registered with its own redirect URI,
client_id+scopes+redirect_portare treated as one coupled bundle.Kernel default bundle:
databricks-sql-connector/sql offline_access/ port8030(wasdatabricks-cli/all-apis offline_access/8020).Changes
src/session.rs): extractresolve_u2m_bundle()+DEFAULT_U2M_CLIENT_ID/DEFAULT_U2M_REDIRECT_PORT/default_u2m_scopes(); the bundle defaults together.src/auth/oauth/u2m.rsDEFAULT_CALLBACK_PORT8020 → 8030;c_abi+callbackdocs updated.NODE_OAUTH_CLIENT_IDoverride so Node — and Go via the C ABI — ride the kernel default. Empty-client_id guard kept.databricks-sql-pythonoverride and additionally pin its registered redirect port (8020) so it does not inherit the new kernel default8030and hitredirect_uri_mismatch. Applied only when the caller relies on the default client_id.pyo3/src/session.rscarries an unrelatedcargo fmtline-wrap.Per-consumer outcome
databricks-sql-connector(kernel default)sql offline_accessdatabricks-sql-connector(kernel default)sql offline_accessdatabricks-sql-pythonsql offline_accessdatabricks-sql-odbcsql offline_accessCross-cloud handling (deliberate)
The kernel treats AWS, GCP, and Azure identically — one default bundle + Databricks-native workspace-OIDC discovery, no cloud branching. The kernel has no Entra-ID/AAD passthrough path, so cloud-specific client selection would not help an AAD-only Azure workspace anyway (native OIDC is required for kernel U2M on any cloud). The AAD passthrough remains a separate concern for the reserved/unwired
OAuthFederation/Externalvariants — out of scope here.Tests
cargo testincl. newsession::u2m_default_tests(2 passed) — default bundle + override passthrough.cargo test u2m(7 passed) — default bundle now assertsredirect_port = Some(8020).cargo test --features dyn-symbols u2m(2 passed) — bare U2M now yieldsclient_id/scopes/redirect_port = None.cargo fmt+clippy --all-targets -D warningsclean on all three crates.localhost:8030callback → token →CreateSession→close). Confirmed the uniform default is accepted by a native-OAuth Azure workspace.Refs: PECOBLR-4039.
This pull request and its description were written by Isaac.