[PECOBLR-2158] feat(rust/oauth): Token primitives, OIDC discovery, cache and token store#320
Open
vikrantpuppala wants to merge 10 commits intoadbc-drivers:mainfrom
Open
[PECOBLR-2158] feat(rust/oauth): Token primitives, OIDC discovery, cache and token store#320vikrantpuppala wants to merge 10 commits intoadbc-drivers:mainfrom
vikrantpuppala wants to merge 10 commits intoadbc-drivers:mainfrom
Conversation
Design for OAuth 2.0 authentication in the Rust ADBC driver covering Authorization Code + PKCE (U2M) and Client Credentials (M2M) flows, including token refresh state machine, file-based caching, and OIDC discovery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use oauth2 crate for PKCE, token exchange, client credentials, and refresh token flows. Eliminates hand-rolled pkce.rs module. - Reuse DatabricksHttpClient for token endpoint calls via execute_without_auth(), giving unified retry/timeout/pooling. - Two-phase initialization: HTTP client created first, auth provider set later via OnceLock (matching SeaClient's reader_factory pattern). - OAuth providers route token requests through the shared HTTP client with a custom oauth2 HTTP function adapter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add AuthMechanism enum: 0=Pat, 11=OAuth (matches ODBC AuthMech) - Add AuthFlow enum: 0=TokenPassthrough, 1=ClientCredentials, 2=Browser (matches ODBC Auth_Flow) - Both mechanism and flow are mandatory, no auto-detection - Accept numeric values only, parsed via TryFrom - Use unified DatabricksHttpClient with two-phase init - Adopt oauth2 crate for protocol-level operations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes: - databricks.oauth.token_endpoint -> databricks.auth.token_endpoint - Config type Int/String -> Int (numeric only) - Clarify oauth2 HTTP adapter needs thin conversion layer - Architecture diagram shows M2M/U2M using execute_without_auth() - Token passthrough (flow=0) documents no auto-refresh - Stale threshold uses initial_TTL computed once at acquisition - Deduplicate http.rs changes (reference Concurrency section) Test strategy additions: - Wiremock integration tests for full M2M flow with mocked HTTP - Database config validation tests for enum parsing and new_connection - HTTP client two-phase init tests for OnceLock lifecycle Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3-task breakdown covering foundation + HTTP client changes, M2M provider, and U2M provider with full test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…-1.1-oauth-token-struct
…D: task-1.4-token-store
This was referenced Mar 8, 2026
62e94c8 to
e0a0fdc
Compare
…task-1.5-oauth-module-setup
e0a0fdc to
fe4a411
Compare
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 suggestion 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
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 supportauthorization_endpointandtoken_endpointfrom/.well-known/oauth-authorization-serverTokenCache— file-based persistence at~/.config/databricks-adbc/oauth/with SHA-256 hashed filenames and0o600permissionsTokenStore— thread-safe token lifecycle (Empty → Fresh → Stale → Expired) with coordinated refresh viaRwLock+AtomicBooloauth2,sha2,dirs,serde,opencratesDatabricksHttpClient— extended withOnceLock-based auth provider andinner()accessor for theoauth2crateKey files
src/auth/oauth/token.rs—OAuthTokenstructsrc/auth/oauth/oidc.rs— OIDC endpoint discoverysrc/auth/oauth/cache.rs— file-based token cachesrc/auth/oauth/token_store.rs— token lifecycle state machinesrc/client/http.rs— HTTP client auth provider integration