[PECOBLR-2160] feat(rust/oauth): U2M and M2M providers with callback server#322
Open
vikrantpuppala wants to merge 16 commits intoadbc-drivers:mainfrom
Open
[PECOBLR-2160] feat(rust/oauth): U2M and M2M providers with callback server#322vikrantpuppala wants to merge 16 commits intoadbc-drivers:mainfrom
vikrantpuppala wants to merge 16 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
104743c to
6006df1
Compare
6006df1 to
e305f9a
Compare
…task-1.5-oauth-module-setup
…: task-2.2-database-config-fields
…2.3-database-validation
…1-callback-server
…sk-3.2-u2m-provider
…3-database-integration
e305f9a to
36b5072
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
Implements both OAuth authentication providers and wires them into
Database::new_connection():CallbackServer— lightweight TCP server on localhost that captures OAuth redirect callbacks, validates CSRF state, extracts authorization codesAuthorizationCodeProvider(U2M) — full authorization code + PKCE flow: browser launch, callback capture, token exchange, refresh token support with disk cachingClientCredentialsProvider(M2M) — client credentials grant withTokenStore-managed lifecycle (initial fetch, stale refresh, expiry re-auth)Database::new_connection()— creates the appropriateAuthProviderbased onAuthConfig(PAT, token passthrough, M2M, or U2M)#[allow(dead_code)]annotations and unusedfetch_tokenduplicateKey files
src/auth/oauth/callback.rs— OAuth redirect callback serversrc/auth/oauth/u2m.rs— U2M authorization code + PKCE providersrc/auth/oauth/m2m.rs— M2M client credentials providersrc/database.rs— auth provider creation innew_connection()