feat(rust): Auth config enums and Database option parsing#321
Closed
vikrantpuppala wants to merge 3 commits intoadbc-drivers:mainfrom
Closed
feat(rust): Auth config enums and Database option parsing#321vikrantpuppala wants to merge 3 commits intoadbc-drivers:mainfrom
vikrantpuppala wants to merge 3 commits intoadbc-drivers:mainfrom
Conversation
This was referenced Mar 8, 2026
Merged
094741a to
f49c83e
Compare
f23bf89 to
2e70c60
Compare
Collaborator
Author
Range-diff: stack/pr-oauth-foundation (f23bf89 -> 2e70c60)
Reproduce locally: |
2e70c60 to
296931c
Compare
vikrantpuppala
added a commit
that referenced
this pull request
Mar 13, 2026
## 🥞 Stacked PR Use this [link](https://github.com/adbc-drivers/databricks/pull/319/files) to review incremental changes. - [**stack/oauth-u2m-m2m-design**](#319) [[Files changed](https://github.com/adbc-drivers/databricks/pull/319/files)] - [stack/pr-oauth-foundation](#320) [[Files changed](https://github.com/adbc-drivers/databricks/pull/320/files/250ff3d91c3001f671f08084f68e949e556bc5d2..bd474c189621aa70c1f14e97c32d64605275e07d)] - [stack/pr-database-config](#321) [[Files changed](https://github.com/adbc-drivers/databricks/pull/321/files/bd474c189621aa70c1f14e97c32d64605275e07d..296931cd396d82dccb1b548a51f6b9d31be3683e)] - [stack/pr-u2m-provider](#322) [[Files changed](https://github.com/adbc-drivers/databricks/pull/322/files/296931cd396d82dccb1b548a51f6b9d31be3683e..c96689981e79c04f43e8251f2cbd5690371dfca5)] - [stack/pr-integration-tests](#323) [[Files changed](https://github.com/adbc-drivers/databricks/pull/323/files/c96689981e79c04f43e8251f2cbd5690371dfca5..83d639337ca30688abb7bdba85aa16426d76eb31)] - [stack/pr-final-validation](#324) [[Files changed](https://github.com/adbc-drivers/databricks/pull/324/files/83d639337ca30688abb7bdba85aa16426d76eb31..e2cd82bf1e9510169735774784591074f30351d3)] --------- ## Summary - Design document for adding OAuth 2.0 authentication to the Rust ADBC driver covering both U2M (Authorization Code + PKCE) and M2M (Client Credentials) flows - Sprint plan breaking the implementation into 3 tasks: foundation + HTTP client changes, M2M provider, U2M provider - Uses the `oauth2` crate for protocol-level operations, unified `DatabricksHttpClient` with two-phase `OnceLock` init, and ODBC-aligned numeric config values (`AuthMech`/`Auth_Flow`) ## Key decisions and alternatives considered - **`oauth2` crate adoption** over hand-rolling OAuth protocol (eliminates ~200 lines of boilerplate, handles PKCE/token exchange/refresh) - **Unified HTTP client** (`DatabricksHttpClient` with `OnceLock`) over separate `reqwest::Client` for token calls (shared retry logic, connection pooling) - **ODBC-aligned numeric config** (`mechanism=0/11`, `flow=0/1/2`) over string-based or auto-detection (explicit, predictable, matches ODBC driver) - **Separate U2M/M2M providers** over single OAuthProvider (different flows, refresh strategies, caching needs) - **Separate token cache** (`~/.config/databricks-adbc/oauth/`) over sharing Python SDK cache (fragile cross-SDK compatibility) ## Areas needing specific review focus - Two-phase HTTP client initialization pattern (OnceLock for auth provider) — is this the right approach for breaking the circular dependency? - Token refresh state machine (FRESH/STALE/EXPIRED) — are the thresholds (40s expiry buffer, min(TTL*0.5, 20min) stale) appropriate? - Config option naming (`databricks.auth.mechanism`, `databricks.auth.flow`) — alignment with ODBC driver - Sprint plan task breakdown — is the scope realistic for 2 weeks? --- *Replaces #318 (closed — converted to stacked branch)* 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
36f6b59 to
1222489
Compare
fce60b0 to
164ada0
Compare
vikrantpuppala
added a commit
that referenced
this pull request
Mar 13, 2026
…tore (#320) ## 🥞 Stacked PR Use this [link](https://github.com/adbc-drivers/databricks/pull/320/files) to review incremental changes. - [**stack/pr-oauth-foundation**](#320) [[Files changed](https://github.com/adbc-drivers/databricks/pull/320/files)] - [stack/pr-database-config](#321) [[Files changed](https://github.com/adbc-drivers/databricks/pull/321/files/78b9ec88459f895c76bd1aea99fcb47e5eb94893..164ada04d14660306c7e44dd3d52a7943050aa27)] - [stack/pr-u2m-provider](#322) [[Files changed](https://github.com/adbc-drivers/databricks/pull/322/files/164ada04d14660306c7e44dd3d52a7943050aa27..abc00ced51d89f1a652f78209f692775eba05e73)] - [stack/pr-integration-tests](#323) [[Files changed](https://github.com/adbc-drivers/databricks/pull/323/files/abc00ced51d89f1a652f78209f692775eba05e73..75b18d6c594eeba89a30450152d6d6f672239614)] - [stack/pr-final-validation](#324) [[Files changed](https://github.com/adbc-drivers/databricks/pull/324/files/75b18d6c594eeba89a30450152d6d6f672239614..2d6ccb09e121015aa6a0da6e992529a686bb0f04)] --------- ## Summary Adds the core OAuth token infrastructure used by both U2M and M2M flows: - **`OAuthToken`** — token struct with expiry tracking, stale detection (40s buffer / 50% TTL), and serde support - **OIDC discovery** — fetches `authorization_endpoint` and `token_endpoint` from `/.well-known/oauth-authorization-server` - **`TokenCache`** — file-based persistence at `~/.config/databricks-adbc/oauth/` with SHA-256 hashed filenames and `0o600` permissions - **`TokenStore`** — thread-safe token lifecycle (Empty → Fresh → Stale → Expired) with coordinated refresh via `RwLock` + `AtomicBool` - **Cargo dependencies** — `oauth2`, `sha2`, `dirs`, `serde`, `open` crates - **`DatabricksHttpClient`** — extended with `OnceLock`-based auth provider and `inner()` accessor for the `oauth2` crate ### Key files - `src/auth/oauth/token.rs` — `OAuthToken` struct - `src/auth/oauth/oidc.rs` — OIDC endpoint discovery - `src/auth/oauth/cache.rs` — file-based token cache - `src/auth/oauth/token_store.rs` — token lifecycle state machine - `src/client/http.rs` — HTTP client auth provider integration
…: task-2.2-database-config-fields
164ada0 to
20b42e7
Compare
…2.3-database-validation
20b42e7 to
3cdbf7c
Compare
Collaborator
Author
|
Folded into PR #322 to reduce stack size. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one sugges
304A
tion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stacked PR
Use this link to review incremental changes.
Summary
Replaces the ODBC-style numeric
AuthMech/Auth_Flowconfig with a single string-baseddatabricks.auth.typeoption:AuthTypeenum (config.rs) —AccessToken,OAuthM2m,OAuthU2mparsed from string values (access_token,oauth_m2m,oauth_u2m)AuthConfig— simplified toauth_type+ credential fields (no moremechanism/flow)Database::set_option— handlesdatabricks.auth.typeas a string; removed numericmechanism/flowparsingDatabase::new_connection— flatmatch auth_typeinstead of nested mechanism/flow matchingConfiguration
Key files
src/auth/config.rs—AuthTypeenum andAuthConfigvalidationsrc/auth/mod.rs— updated re-exportssrc/database.rs— option parsing andnew_connection()auth provider creationThis pull request was AI-assisted by Isaac.