Skip to content

feat(napi): expose token_url for M2M / JWT client-assertion auth - #275

Merged
rahuls-db merged 2 commits into
mainfrom
feat/napi-token-url
Aug 20, 2026
Merged

rahuls-db merged 2 commits into
mainfrom
feat/napi-token-url

Conversation

@rahuls-db

Copy link
Copy Markdown
Collaborator

What

Exposes token_url (OAuth token-endpoint override) on the napi binding's ConnectionOptions, for both the OAuthM2m and OAuthM2mJwt auth modes.

Why

The napi binding hardcoded None for the token-endpoint override on both the M2M and JWT client-assertion paths, so a Node caller could not point the client-credentials / JWT client-assertion grant at the workspace's OAuth IdP token endpoint.

That endpoint is required for JWT private-key M2M (AuthMode.OAuthM2mJwt) against an external-IdP-backed workspace — e.g. Entra ID for Azure Databricks — because Databricks-native OIDC does not advertise the private_key_jwt client-authentication method. Without token_url, JWT M2M through the Node driver could only use OIDC discovery and would fail against exactly the workspaces where the feature is meant to be used.

pyo3 already exposes this as token_url; this brings napi to parity. Follow-up to the JWT private-key M2M feature (#249, merged).

How

  • Add ConnectionOptions.token_url (camelCase tokenUrl in index.d.ts).
  • Thread it into AuthConfig::oauth_m2m (was None) and AuthConfig::oauth_m2m_private_key (was None).
  • Extend the JWT parity test to assert the override reaches token_url_override.

Testing

  • cargo test -p databricks-sql-kernel-napi --features dyn-symbols — 72 passed.
  • cargo clippy --all-targets --features dyn-symbols -- -D warnings clean; cargo fmt clean.
  • Verified end-to-end via the Node driver (databricks-sql-nodejs, useKernel: true) against an Azure Databricks warehouse: SELECT 1 authenticated by Entra ID with a JWT private-key client assertion, using tokenUrl pointed at the Entra token endpoint. (See companion databricks-sql-nodejs PR.)

This pull request and its description were written by Isaac.

The napi binding hardcoded `None` for the token-endpoint override on both
the OAuthM2m and OAuthM2mJwt paths, so a Node caller could not point the
client-credentials / JWT client-assertion grant at the workspace's OAuth
IdP token endpoint. That endpoint is required for JWT private-key M2M
against an external-IdP-backed workspace (e.g. Entra ID for Azure
Databricks), since Databricks-native OIDC does not advertise the
`private_key_jwt` client-authentication method.

Add `ConnectionOptions.token_url` (camelCase `tokenUrl` in the .d.ts) and
thread it into both `AuthConfig::oauth_m2m` and
`AuthConfig::oauth_m2m_private_key`. pyo3 already exposes this
(`token_url`); this brings napi to parity. Extends the JWT parity test to
assert the override flows through.

Co-authored-by: Isaac
Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — clean, well-scoped parity change. Argument ordering into AuthConfig::oauth_m2m and AuthConfig::oauth_m2m_private_key matches the kernel builder signatures in src/config.rs (scopes → token_url_override → identity_federation), docs and changelog are consistent. One Low: the M2M (non-JWT) path change is not covered by a test assertion, only the JWT path is.

Comment thread napi/src/database.rs
options.oauth_client_secret.clone(),
options.oauth_scopes.clone(),
None,
options.token_url.clone(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — The OAuthM2m path also changed from hardcoded None to options.token_url.clone(), but only the JWT (OAuthM2mJwt) test was extended to assert the override reaches token_url_override. The m2m_requires_client_id_and_secret test (lines 734-763) sets oauth_scopes/identity_federation_client_id and matches on AuthConfig::OAuthM2M { .. } asserting only scopes — it never sets token_url nor asserts it is threaded through. So the M2M half of this change is untested. Consider setting o.token_url and asserting token_url_override in the M2M test too, mirroring the JWT test, to guard against a future regression in argument order on that call site.

Bind the test token URL to a local so the assert line is short enough that
no rustfmt version (CI's differs from local stable) wants to reflow it.

Co-authored-by: Isaac
Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — correct, well-scoped napi parity change. Verified both kernel constructors (AuthConfig::oauth_m2m / oauth_m2m_private_key) against the napi threading; token_url lands in the correct positional token_url_override slot on both paths. One low note: only the JWT path has a test asserting the override propagates.

Comment thread napi/src/database.rs
options.oauth_client_secret.clone(),
options.oauth_scopes.clone(),
None,
options.token_url.clone(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — The token_url override is now threaded into both the OAuthM2m and OAuthM2mJwt paths, but only the JWT path (OAuthM2MPrivateKey) gained a test asserting the value reaches token_url_override. The plain AuthMode.OAuthM2m path here is left without coverage for the new argument, so a future regression (e.g. reverting to None or swapping it with identity_federation_client_id) on the M2M branch would not be caught. Consider extending the M2M build_auth_config test to assert token_url_override as well.

@rahuls-db
rahuls-db added this pull request to the merge queue Aug 20, 2026
Merged via the queue into main with commit c4b94e3 Aug 20, 2026
18 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — 4d651094 Deployed Aug 20, 2026 by oss-reviewer-bot[bot] via followup #763
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants