Repository navigation
feat(database): add databricks oauth support - #34619
drummerwolli wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Duplicated OAuth2 Configuration ▹ view | ✅ Fix detected | |
| OAuth Client Secrets Exposed in Config File ▹ view | 🧠 Incorrect | |
| Hardcoded OAuth2 endpoints limit cloud provider support ▹ view | ✅ Fix detected |
Files scanned
| File Path | Reviewed |
|---|---|
| superset/db_engine_specs/databricks.py | ✅ |
| docs/docs/configuration/databases.mdx | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
| oauth2_authorization_request_uri = ( | ||
| "https://accounts.cloud.databricks.com/oidc/accounts/{}/v1/authorize" | ||
| ) | ||
| oauth2_token_request_uri = ( | ||
| "https://accounts.cloud.databricks.com/oidc/accounts/{}/v1/token" # noqa: S105 | ||
| ) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| oauth2_authorization_request_uri = ( | ||
| "https://accounts.cloud.databricks.com/oidc/accounts/{}/v1/authorize" | ||
| ) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| DATABASE_OAUTH2_CLIENTS = { | ||
| "Databricks (legacy)": { | ||
| "id": "your-databricks-client-id", | ||
| "secret": "your-databricks-client-secret", | ||
| "scope": "sql", | ||
| "authorization_request_uri": "https://accounts.cloud.databricks.com/oidc/accounts/{account_id}/v1/authorize", | ||
| "token_request_uri": "https://accounts.cloud.databricks.com/oidc/accounts/{account_id}/v1/token", | ||
| }, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #34619 +/- ##
==========================================
- Coverage 64.37% 63.78% -0.59%
==========================================
Files 2653 2653
Lines 145177 145240 +63
Branches 33495 33503 +8
==========================================
- Hits 93457 92643 -814
- Misses 50025 50900 +875
- Partials 1695 1697 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I'm currently testing this internally and will report back here, hence there might not be any visible activity in this PR in the next days. |
|
@drummerwolli checking back in on this, the Databricks OAuth support looks worth landing. Did the internal testing pan out? It'll need a rebase and a unit-test fix to go green, so I'll tacke this now and leave it open for further review. |
There was a problem hiding this comment.
Code Review Agent Run #6cc2a6
Actionable Suggestions - 1
-
superset/db_engine_specs/databricks.py - 1
- CWE-20: Unformatted Placeholders in OAuth2 URI · Line 731-733
Additional Suggestions - 1
-
tests/unit_tests/db_engine_specs/test_databricks.py - 1
-
SEMANTIC_DUPLICATION | Test consolidation needed · Line 660-694This test is semantically identical to `test_get_oauth2_fresh_token_native` (lines 623-657). Neither `DatabricksNativeEngineSpec` nor `DatabricksPythonConnectorEngineSpec` overrides `get_oauth2_fresh_token`, so both call the same `BaseEngineSpec` implementation with identical configuration. Consider consolidating or testing a meaningful behavioral difference.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
tests/unit_tests/db_engine_specs/test_databricks.py - 1
- Missing pytest fixture decorator · Line 395-400
-
docs/docs/configuration/databases.mdx - 1
- Incorrect cloud_provider placement · Line 580-584
-
superset/db_engine_specs/databricks.py - 1
- CWE-345: Duplicate Azure OAuth2 token bug · Line 751-759
Review Details
-
Files reviewed - 4 · Commit Range:
732f66b..0b786fc- docs/docs/configuration/databases.mdx
- superset/db_engine_specs/databricks.py
- tests/unit_tests/db_engine_specs/test_databricks.py
- tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| "authorization_request_uri": cls._oauth2_endpoints[provider][ | ||
| "authorization_request_uri" | ||
| ] |
There was a problem hiding this comment.
OAuth2 endpoints contain {} placeholders for account/tenant IDs that are never filled. Azure authorization will request https://login.microsoftonline.com//oauth2/v2.0/authorize (double slash) because {} is passed literally. AWS/GCP will similarly receive malformed URIs. Extract the appropriate ID from database.extra JSON (e.g., aws_account_id, azure_tenant_id) and call .format(account_id) on the endpoint string before use. (CWE-20)
Code suggestion
Check the AI-generated fix before applying
provider = cls._detect_cloud_provider(database)
+ import json
+ extra_config = json.loads(database.extra or "{}")
+
+ # Get the appropriate account/tenant ID for the provider
+ account_id = (
+ extra_config.get("azure_tenant_id") or
+ extra_config.get("aws_account_id") or
+ ""
+ )
+
from typing import cast
config = cast(
"OAuth2ClientConfig",
dict(config)
| {
"authorization_request_uri": cls._oauth2_endpoints[provider][
- "authorization_request_uri"
- ]
+ "authorization_request_uri"
+ ].format(account_id)
},
)
return super().get_oauth2_authorization_uri(config, state)
Code Review Run #6cc2a6
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
0b786fc to
1f7898c
Compare
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_database_aws(mocker: MockerFixture): |
There was a problem hiding this comment.
Suggestion: Add an explicit return type annotation to this fixture so the new function is fully typed. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
This is a newly added Python fixture function and it lacks a return type annotation.
The rule requires new Python functions to be fully typed, including return values.
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
**Line:** 35:35
**Comment:**
*Custom Rule: Add an explicit return type annotation to this fixture so the new function is fully typed.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| } | ||
|
|
||
|
|
||
| def test_cloud_provider_detection_aws(mock_database_aws) -> None: |
There was a problem hiding this comment.
Suggestion: Add a concrete type hint for the fixture argument used by this test function. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
This new test function has an untyped parameter, mock_database_aws.
The custom rule requires newly added Python functions to be fully typed, so this is a real violation.
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
**Line:** 86:86
**Comment:**
*Custom Rule: Add a concrete type hint for the fixture argument used by this test function.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| def test_get_oauth2_authorization_uri_aws( | ||
| mocker: MockerFixture, | ||
| oauth2_config: OAuth2ClientConfig, | ||
| mock_database_aws, | ||
| ) -> None: |
There was a problem hiding this comment.
Suggestion: Add a type annotation for the mock_database_aws parameter in this new test function signature. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
The function is newly added and one of its parameters, mock_database_aws, has no type annotation.
That violates the rule requiring new Python functions to be fully typed.
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
**Line:** 128:132
**Comment:**
*Custom Rule: Add a type annotation for the `mock_database_aws` parameter in this new test function signature.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| def test_get_oauth2_authorization_uri_azure( | ||
| mocker: MockerFixture, | ||
| oauth2_config: OAuth2ClientConfig, | ||
| mock_database_azure, | ||
| ) -> None: |
There was a problem hiding this comment.
Suggestion: Add a type annotation for the untyped fixture parameter in this function signature. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
This is a new function and it includes an untyped parameter, mock_database_azure.
The rule explicitly requires full type hints for new Python functions, so the suggestion is valid.
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
**Line:** 160:164
**Comment:**
*Custom Rule: Add a type annotation for the untyped fixture parameter in this function signature.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| def test_python_connector_oauth2_authorization_uri_azure( | ||
| mocker: MockerFixture, | ||
| oauth2_config: OAuth2ClientConfig, | ||
| mock_database_azure, | ||
| ) -> None: |
There was a problem hiding this comment.
Suggestion: Add a type hint for the mock_database_azure argument so all parameters in this new function are typed. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
The new test function has an untyped parameter, mock_database_azure.
This matches the custom rule that newly added Python functions must be fully typed.
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
**Line:** 233:237
**Comment:**
*Custom Rule: Add a type hint for the `mock_database_azure` argument so all parameters in this new function are typed.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| _oauth2_endpoints = { | ||
| "aws": { | ||
| "authorization_request_uri": "https://accounts.cloud.databricks.com/oidc/accounts/{}/v1/authorize", | ||
| "token_request_uri": "https://accounts.cloud.databricks.com/oidc/accounts/{}/v1/token", | ||
| }, | ||
| "azure": { | ||
| "authorization_request_uri": "https://login.microsoftonline.com/{}/oauth2/v2.0/authorize", | ||
| "token_request_uri": "https://login.microsoftonline.com/{}/oauth2/v2.0/token", | ||
| }, | ||
| "gcp": { | ||
| "authorization_request_uri": "https://accounts.gcp.databricks.com/oidc/accounts/{}/v1/authorize", | ||
| "token_request_uri": "https://accounts.gcp.databricks.com/oidc/accounts/{}/v1/token", | ||
| }, | ||
| } |
There was a problem hiding this comment.
Suggestion: The OAuth endpoint templates contain {} placeholders but no formatting step ever fills them with account/tenant identifiers. This generates invalid authorization/token URLs (for example paths with empty or literal placeholder segments), causing OAuth requests to fail against real providers. Build concrete URIs from required config values before sending users to OAuth endpoints. [api mismatch]
Severity Level: Critical 🚨
- ❌ Databricks OAuth2 login redirects to invalid authorization URLs.
- ⚠️ Users cannot complete OAuth2 authentication for Databricks.Steps of Reproduction ✅
1. Configure an OAuth2 client for Databricks (either globally in `DATABASE_OAUTH2_CLIENTS`
or per-database in `encrypted_extra["oauth2_client_info"]`) so that
`Database.get_oauth2_config()` returns a valid `OAuth2ClientConfig` (see
`superset/models/core.py:33-43` and `superset/db_engine_specs/base.py:725-175`).
2. Trigger OAuth2 for a Databricks database (native or Python connector) without an
existing token, so `Database.start_oauth2_dance()` calls
`db_engine_spec.start_oauth2_dance(self)`; `BaseEngineSpec.start_oauth2_dance` at
`superset/db_engine_specs/base.py:643-143` then calls
`cls.get_oauth2_authorization_uri(oauth2_config, state, code_verifier=...)`.
3. In `DatabricksNativeEngineSpec.get_oauth2_authorization_uri` or
`DatabricksPythonConnectorEngineSpec.get_oauth2_authorization_uri`
(`superset/db_engine_specs/databricks.py:158-188` and `435-465`), the method detects the
cloud provider via `_detect_cloud_provider` and overwrites
`config["authorization_request_uri"]` with the corresponding template from
`_oauth2_endpoints` defined at `superset/db_engine_specs/databricks.py:287-300`, such as
`"https://accounts.cloud.databricks.com/oidc/accounts/{}/v1/authorize"`, without
substituting the `{}` placeholder.
4. `BaseEngineSpec.get_oauth2_authorization_uri` at
`superset/db_engine_specs/base.py:178-206` then uses this unformatted template as `uri`
and appends query parameters, producing an authorization URL whose path still contains
`"{}"` instead of an account/tenant identifier, leading the identity provider
(Databricks/Azure/GCP) to reject or 404 the request when the browser is redirected.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/db_engine_specs/databricks.py
**Line:** 287:300
**Comment:**
*Api Mismatch: The OAuth endpoint templates contain `{}` placeholders but no formatting step ever fills them with account/tenant identifiers. This generates invalid authorization/token URLs (for example paths with empty or literal placeholder segments), causing OAuth requests to fail against real providers. Build concrete URIs from required config values before sending users to OAuth endpoints.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| supports_oauth2 = True | ||
| oauth2_exception = OAuth2RedirectError | ||
| oauth2_scope = "sql" |
There was a problem hiding this comment.
Suggestion: OAuth2 is enabled without enforcing per-user query caching for this engine. Since authentication becomes user-token based, shared cache entries can be reused across users unless per-user caching is forced, which can leak one user's results to another. Add backend enforcement so OAuth2-enabled Databricks connections always use per-user cache keys. [cache]
Severity Level: Critical 🚨
- ❌ Databricks OAuth2 query cache entries may leak between users.
- ⚠️ Cache behavior conflicts with per-user auth expectations.
- ⚠️ Security posture weaker than required for OAuth2 engines.Steps of Reproduction ✅
1. Observe that `DatabricksNativeEngineSpec` and `DatabricksPythonConnectorEngineSpec`
declare `supports_oauth2 = True` and define `impersonate_user` to inject a per-user OAuth2
access token into the SQLAlchemy URL/connect_args at
`superset/db_engine_specs/databricks.py:328-349` and `116-139`, while
`Database._get_sqla_engine` in `superset/models/core.py:28-49` calls
`self.db_engine_spec.impersonate_user(self, effective_username, access_token,
sqlalchemy_url, engine_kwargs)` when `self.impersonate_user` is true.
2. Query caching keys are constructed in `viz.BaseViz.cache_key` at
`superset/viz.py:504-513`, which calls
`add_impersonation_cache_key_if_needed(self.datasource.database, cache_dict)` before
hashing, so per-user cache separation only happens if that helper adds an
`"impersonation_key"`.
3. `add_impersonation_cache_key_if_needed` in `superset/utils/cache_keys.py:33-25` adds an
impersonation-based cache key only when one of the following holds: (a) feature flag
`CACHE_IMPERSONATION` is enabled and `database.impersonate_user` is true, (b) feature flag
`CACHE_QUERY_BY_USER` is enabled, or (c) `database.extra` JSON sets `"per_user_caching":
true`; it does not automatically enforce per-user cache keys for OAuth2-enabled engines.
4. In a Databricks OAuth2 configuration where `supports_oauth2` is true, the connection
uses per-user tokens via `impersonate_user`, but the admin has neither enabled
`per_user_caching` nor the relevant feature flags, different users issuing the same query
against the same Databricks database will get identical cache keys and share cached
results, potentially exposing one user's query results to another despite authentication
being per-user.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/db_engine_specs/databricks.py
**Line:** 549:551
**Comment:**
*Cache: OAuth2 is enabled without enforcing per-user query caching for this engine. Since authentication becomes user-token based, shared cache entries can be reused across users unless per-user caching is forced, which can leak one user's results to another. Add backend enforcement so OAuth2-enabled Databricks connections always use per-user cache keys.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| oauth2_token_request_uri = "" # Set dynamically | ||
|
|
There was a problem hiding this comment.
Suggestion: The class declares an empty default token endpoint while relying on base refresh-token logic, which uses config["token_request_uri"] directly. With the documented auto-detection setup (no explicit token URI), refresh requests will call an empty URL and fail at runtime. Ensure a concrete token endpoint is resolved for refresh flows too, not only initial code exchange. [incomplete implementation]
Severity Level: Major ⚠️
- ❌ Databricks OAuth2 access tokens cannot be refreshed.
- ⚠️ Users lose connectivity once initial tokens expire.
- ⚠️ Admins cannot rely on documented optional token URI default.Steps of Reproduction ✅
1. Configure a Databricks OAuth2 client only with `id` and `secret` in
`DATABASE_OAUTH2_CLIENTS` (leaving `"token_request_uri"` unset), so
`BaseEngineSpec.get_oauth2_config` at `superset/db_engine_specs/base.py:725-175` builds a
config where `config["token_request_uri"]` falls back to `cls.oauth2_token_request_uri`.
2. For `DatabricksNativeEngineSpec` or `DatabricksPythonConnectorEngineSpec`,
`oauth2_token_request_uri` is explicitly set to an empty string at
`superset/db_engine_specs/databricks.py:555-556` and `432-433`, so
`config["token_request_uri"]` becomes `""` when no explicit token URI is provided.
3. After an initial token has been obtained (despite other issues), when the access token
expires, `superset/utils/oauth2.get_oauth2_access_token` at
`superset/utils/oauth2.py:9-45` calls `refresh_oauth2_token`, which in turn calls
`db_engine_spec.get_oauth2_fresh_token(config, token.refresh_token)` using the same
`config` with `token_request_uri=""`.
4. Since Databricks specs do not override `get_oauth2_fresh_token`,
`BaseEngineSpec.get_oauth2_fresh_token` at `superset/db_engine_specs/base.py:244-260` uses
`config["token_request_uri"]` as `uri` in `requests.post(uri, data=req_body,
timeout=timeout)`; with `uri=""`, the HTTP client raises an invalid-URL error and token
refresh fails, breaking Databricks OAuth2 connections once tokens expire when admins rely
on engine defaults for the token URI.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/db_engine_specs/databricks.py
**Line:** 555:556
**Comment:**
*Incomplete Implementation: The class declares an empty default token endpoint while relying on base refresh-token logic, which uses `config["token_request_uri"]` directly. With the documented auto-detection setup (no explicit token URI), refresh requests will call an empty URL and fail at runtime. Ensure a concrete token endpoint is resolved for refresh flows too, not only initial code exchange.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| "OAuth2ClientConfig", | ||
| dict(config) | ||
| | {"token_request_uri": cls._oauth2_endpoints["aws"]["token_request_uri"]}, | ||
| ) | ||
|
|
There was a problem hiding this comment.
Suggestion: Token exchange is hardcoded to AWS endpoints for all Databricks providers. For Azure and GCP connections this sends authorization codes to the wrong token endpoint, which will fail token exchange and break OAuth login. Use the same provider-specific endpoint resolution used for authorization URI generation. [api mismatch]
Severity Level: Critical 🚨
- ❌ Azure Databricks OAuth2 login fails at token exchange.
- ❌ GCP Databricks OAuth2 login fails at token exchange.
- ⚠️ Multi-cloud Databricks OAuth2 support is effectively unusable.Steps of Reproduction ✅
1. Configure a Databricks database whose hostname indicates Azure or GCP (e.g.
`adb-...azuredatabricks.net` or `...gcp.databricks.com`) so that `_detect_cloud_provider`
in `superset/db_engine_specs/databricks.py:303-326` returns `"azure"` or `"gcp"`, and set
up a valid OAuth2 client so `Database.get_oauth2_config()` succeeds.
2. Complete the OAuth2 authorization step so the provider (Azure or GCP) redirects back to
Superset with an authorization `code`; `DatabaseOAuth2Command.run` in
`superset/commands/database/oauth2.py:40-39` then retrieves `oauth2_config` via
`self._database.get_oauth2_config()` and calls
`self._database.db_engine_spec.get_oauth2_token(oauth2_config, code, code_verifier)`.
3. In `DatabricksNativeEngineSpec.get_oauth2_token` and
`DatabricksPythonConnectorEngineSpec.get_oauth2_token`
(`superset/db_engine_specs/databricks.py:191-213` and `468-490`), the code constructs a
new config via `dict(config) | {"token_request_uri":
cls._oauth2_endpoints["aws"]["token_request_uri"]}`, forcing the token exchange to always
target the AWS Databricks token endpoint defined in
`_oauth2_endpoints["aws"]["token_request_uri"]` regardless of the actual cloud provider.
4. `BaseEngineSpec.get_oauth2_token` at `superset/db_engine_specs/base.py:209-241` then
POSTs the Azure- or GCP-issued authorization code to this AWS endpoint, which will reject
the foreign code, causing an HTTP error and preventing `DatabaseOAuth2Command.run` from
storing any tokens for non-AWS Databricks deployments.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/db_engine_specs/databricks.py
**Line:** 607:611
**Comment:**
*Api Mismatch: Token exchange is hardcoded to AWS endpoints for all Databricks providers. For Azure and GCP connections this sends authorization codes to the wrong token endpoint, which will fail token exchange and break OAuth login. Use the same provider-specific endpoint resolution used for authorization URI generation.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
Code Review Agent Run #8b6a9fActionable Suggestions - 0Additional SuggestionsFiltered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules. Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
@rusackas unfortunately we pivoted away from Databricks and are moving now to Databricks native tooling now instead (Dashboards, SQL Editor, Genie). So there is no interest anymore from my side to continue here. i'm happy if someone else wants to pick up where i left off. |
|
Thanks for the honest update @drummerwolli, and no worries at all. The OAuth support still looks worth landing, so I'll adopt this and carry it the rest of the way including getting the unit tests green. Appreciate the work you put in here. |
|
Closing in favor of #41421. Thanks again @drummerwolli |
SUMMARY
OAuth 2.0 support for Databricks
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
tbd
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION