Skip to content

feat(auth): default U2M OAuth app to databricks-sql-connector - #247

Merged
eric-wang-1990 merged 5 commits into
mainfrom
eric-wang-1990/u2m-default-oauth-app
Aug 13, 2026
Merged

eric-wang-1990 merged 5 commits into
mainfrom
eric-wang-1990/u2m-default-oauth-app

Conversation

@eric-wang-1990

@eric-wang-1990 eric-wang-1990 commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

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_port are treated as one coupled bundle.

Kernel default bundle: databricks-sql-connector / sql offline_access / port 8030 (was databricks-cli / all-apis offline_access / 8020).

Changes

  • kernel core (src/session.rs): extract resolve_u2m_bundle() + DEFAULT_U2M_CLIENT_ID / DEFAULT_U2M_REDIRECT_PORT / default_u2m_scopes(); the bundle defaults together. src/auth/oauth/u2m.rs DEFAULT_CALLBACK_PORT 8020 → 8030; c_abi + callback docs updated.
  • napi: remove the NODE_OAUTH_CLIENT_ID override so Node — and Go via the C ABI — ride the kernel default. Empty-client_id guard kept.
  • 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. Applied only when the caller relies on the default client_id.
  • pyo3/src/session.rs carries an unrelated cargo fmt line-wrap.

Per-consumer outcome

Consumer client_id scopes port
Node (napi) databricks-sql-connector (kernel default) sql offline_access 8030
Go (C ABI) databricks-sql-connector (kernel default) sql offline_access 8030
Python (pyo3) databricks-sql-python sql offline_access 8020
ODBC (C ABI) overrides in its own repo → databricks-sql-odbc sql offline_access (ODBC app port)

Cross-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 / External variants — out of scope here.

Tests

  • core: cargo test incl. new session::u2m_default_tests (2 passed) — default bundle + override passthrough.
  • pyo3: cargo test u2m (7 passed) — default bundle now asserts redirect_port = Some(8020).
  • napi: cargo test --features dyn-symbols u2m (2 passed) — bare U2M now yields client_id/scopes/redirect_port = None.
  • cargo fmt + clippy --all-targets -D warnings clean on all three crates.
  • live E2E: bare-default U2M browser flow verified end-to-end against a live workspace (OIDC discovery → browser authorize → localhost:8030 callback → 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.

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>

@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.

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 AuthConfig doc 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", "U2M redirect_port defaults to 8020", "U2M client_id defaults 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.

Comment thread napi/src/database.rs Resolved
Comment thread pyo3/src/auth.rs Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The comment are wrong, it is no longer databricks-cli

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)).

@eric-wang-1990 eric-wang-1990 added the engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up label Aug 13, 2026
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>

@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.

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 AuthConfig rustdoc 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 in resolve_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 be 8030.

  • L294: U2M `client_id` defaults to `"databricks-cli"` → should be "databricks-sql-connector".

  • L324/326: the per-field OAuthU2M docs (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 scopes is 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::OAuthU2m branch comment in this (legacy ADBC) AuthConfig::validate still 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>

@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.

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.

Comment thread src/auth/oauth/u2m.rs Resolved
Addresses:
  - #3778529395 at src/auth/oauth/u2m.rs:60

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@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.

✅ No issues identified by the review bot.

This branch was previously deployed

1 inactive deployment
azure-prod — 35bf1edf Deployed Aug 13, 2026 by oss-reviewer-bot[bot] via followup #283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants