Skip to content

Commit b0a674d

Browse files
committed
fix(kernel): forward token_url on shared-secret M2M too (JDBC parity)
Address peco-review-bot: the CONNECTION_PARAMETERS.md row said token_url "applies to shared-secret M2M too", but the bridge only forwarded it on the JWT branch — so an oauth_client_id + oauth_client_secret + token_url connection silently dropped token_url. token_url is an auth-method-agnostic token-endpoint override: JDBC's OAuth2ConnAuthTokenEndpoint is consumed by the client-secret M2M provider, the JWT provider, and the refresh provider alike; the Node driver also forwards it on both branches; and the kernel's oauth-m2m auth_type accepts it (pyo3). Forward it on the shared-secret M2M branch so code matches the doc and the other drivers. Adds a unit test. Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>
1 parent 473ba16 commit b0a674d

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/databricks/sql/backend/kernel/auth_bridge.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ def kernel_auth_kwargs(
312312
scopes = _normalize_scopes(opts.get("oauth_scopes"))
313313
if scopes is not None:
314314
kwargs["oauth_scopes"] = scopes
315+
# token_url is an auth-method-agnostic token-endpoint override (JDBC's
316+
# OAuth2ConnAuthTokenEndpoint applies it to client-secret M2M too), so
317+
# forward it here as well as on the JWT path.
318+
token_url = opts.get("token_url")
319+
if token_url:
320+
kwargs["token_url"] = token_url
315321
if federation_client_id:
316322
kwargs["identity_federation_client_id"] = federation_client_id
317323
return kwargs

tests/unit/test_kernel_auth_bridge.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ def test_m2m_includes_scopes_when_provided(self):
213213
)
214214
assert kwargs["oauth_scopes"] == ["all-apis", "sql"]
215215

216+
def test_m2m_forwards_token_url(self):
217+
# token_url is an auth-agnostic token-endpoint override (JDBC parity),
218+
# so the shared-secret M2M path forwards it too — not just JWT.
219+
kwargs = kernel_auth_kwargs(
220+
_FakeOAuthProvider(),
221+
{
222+
"oauth_client_id": "sp-uuid",
223+
"oauth_client_secret": "shh",
224+
"token_url": "https://login.microsoftonline.com/t/oauth2/v2.0/token",
225+
},
226+
)
227+
assert kwargs["token_url"] == "https://login.microsoftonline.com/t/oauth2/v2.0/token"
228+
216229
def test_m2m_normalizes_space_delimited_scopes(self):
217230
# DatabricksOAuthProvider stores scopes as a single
218231
# space-delimited string; the bridge splits it to a list.

0 commit comments

Comments
 (0)