Skip to content

feat(auth): gate OAuth modules behind an optional 'oauth' Cargo feature - #91

Closed
gopalldb wants to merge 3 commits into
mainfrom
feat-auth-optional-oauth-feature
Closed

gopalldb wants to merge 3 commits into
mainfrom
feat-auth-optional-oauth-feature

Conversation

@gopalldb

Copy link
Copy Markdown
Collaborator

Summary

Make oauth2, open, dirs, sha2 optional deps gated behind a new oauth Cargo feature. Default is on, so existing consumers (pyo3/, napi/, kernel CI, any direct-Rust caller using AuthConfig::OAuthM2M / OAuthU2M) see no behaviour change.

Motivation

The upcoming MultiKernelDriverBenchmark perf suite in databricks-eng/universe consumes the kernel via universe's Rust-crate vendoring system (each crate's full source is committed under third_party/rust/crates/). The benchmark only authenticates with PAT and never touches OAuth at runtime, but with oauth2/open as unconditional kernel deps, universe was forced to vendor and review ~12k lines of source it would never execute. This gate lets the universe side opt out via --no-default-features --features tls-native.

What's gated

  • auth::oauth module (whole subtree).
  • AuthConfig::OAuthM2M / OAuthU2M / OAuthFederation variants + their Debug redaction arms + the redaction tests in src/config.rs.
  • build_auth_provider OAuth match arms in src/session.rs, plus the imports of AuthorizationCodeProvider / ClientCredentialsProvider.
  • util::runtime::block_on_in_runtime (only the OAuth providers' synchronous AuthProvider::get_auth_header impls call it).
  • tests/oauth_u2m_integration.rs (whole-file #![cfg(feature = "oauth")]) and the OAuth-specific arms of tests/v0_session_e2e.rs.

AuthConfig::Pat and AuthConfig::External remain unconditional.

Verification

Ran the full pre-commit checklist (per CLAUDE.md) in both feature configs:

Command oauth on (default) oauth off
cargo test --lib 507 tests pass 462 tests pass — the 45 OAuth-specific tests correctly compile out
cargo clippy --all-targets -- -D warnings clean clean
cargo fmt --all -- --check clean clean

Compatibility

  • Wire-protocol: unchanged.
  • Public surface for default-feature consumers: unchanged (variants present, modules present, re-exports present).
  • Public surface for oauth-off consumers: 3 AuthConfig variants + crate::auth::oauth::* symbols are absent. Match statements over AuthConfig get smaller (PAT + External only). Wrappers that compile against default-features = true see no difference.

DCO sign-off included; commit message follows conventional-commits per repo convention.

Make `oauth2`, `open`, `dirs`, `sha2` optional deps gated behind a new
`oauth` Cargo feature. The feature is **on by default**, so existing
consumers (pyo3, napi, kernel CI, anyone using `AuthConfig::OAuthM2M` /
`OAuthU2M`) see no behaviour change.

The `oauth`-off build is exercised by the upcoming
`MultiKernelDriverBenchmark` perf suite in `databricks-eng/universe`,
which only authenticates with PAT. Shipping the ~12k lines of `oauth2`
+ `open` source through universe's Rust-crate vendoring system for a
code path the benchmark never executes is wasted review surface; this
PR lets the universe side opt out via
`--no-default-features --features tls-native`.

What's gated:
- `auth::oauth` module (whole subtree).
- `AuthConfig::OAuthM2M` / `OAuthU2M` / `OAuthFederation` variants +
  their Debug-redaction arms + the redaction tests.
- `build_auth_provider` OAuth match arms in `session.rs` plus the
  imports of `AuthorizationCodeProvider` / `ClientCredentialsProvider`.
- `util::runtime::block_on_in_runtime` (only OAuth providers' sync
  `AuthProvider::get_auth_header` impls call it).
- `tests/oauth_u2m_integration.rs` (whole-file) and the OAuth
  variants in `tests/v0_session_e2e.rs`.

`AuthConfig::Pat` and `AuthConfig::External` stay unconditional.

Verified both modes locally:
- `cargo test --lib` (default features) — 507 tests pass.
- `cargo test --lib --no-default-features --features tls-native` —
  462 tests pass (the 45 OAuth-specific tests correctly compile out).
- `cargo clippy --all-targets -- -D warnings` passes in both configs.
- `cargo fmt --all -- --check` passes.

Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
None of these are caused by the OAuth gating change; they are
pre-existing drift / new transitive dependencies that this PR
happens to surface. Fixed here to unblock CI.

1. fmt drift in src/reader/cloudfetch/arrow_parser.rs (chain
   layout at L63 and L225). `cargo fmt --all` reflow only.

2. Two doc tests at src/session.rs:488 and src/config.rs:365
   used `TlsConfig { custom_ca_cert: ..., ..TlsConfig::default() }`
   struct-literal construction. `TlsConfig` is `#[non_exhaustive]`,
   and doc tests compile as an external crate, so E0639 fires.
   Switched to the mutate-after-default pattern, matching how
   `ResultConfig` is already constructed externally (see PR #70).

3. tiny-keccak v2.0.2 (transitive via ahash -> const-random ->
   const-random-macro) carries CC0-1.0, which was missing from
   the deny.toml allow-list. CC0-1.0 is FSF-Free and effectively
   public-domain dedication, so adding it is consistent with the
   existing permissive allow-list (Apache-2.0, MIT, ISC, etc.).

Signed-off-by: Gopal Lal <gopal.lal@databricks.com>

This branch had an error being deployed

1 failed deployment
azure-prod — a1714bc4 Deployed Jun 1, 2026 by gopalldb via v0 E2E surface #3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant