Repository navigation
feat(napi): expose token_url for M2M / JWT client-assertion auth - #275
Conversation
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>
There was a problem hiding this comment.
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.
| options.oauth_client_secret.clone(), | ||
| options.oauth_scopes.clone(), | ||
| None, | ||
| options.token_url.clone(), |
There was a problem hiding this comment.
🔵 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>
There was a problem hiding this comment.
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.
| options.oauth_client_secret.clone(), | ||
| options.oauth_scopes.clone(), | ||
| None, | ||
| options.token_url.clone(), |
There was a problem hiding this comment.
🔵 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.
What
Exposes
token_url(OAuth token-endpoint override) on the napi binding'sConnectionOptions, for both theOAuthM2mandOAuthM2mJwtauth modes.Why
The napi binding hardcoded
Nonefor 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 theprivate_key_jwtclient-authentication method. Withouttoken_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
ConnectionOptions.token_url(camelCasetokenUrlinindex.d.ts).AuthConfig::oauth_m2m(wasNone) andAuthConfig::oauth_m2m_private_key(wasNone).token_url_override.Testing
cargo test -p databricks-sql-kernel-napi --features dyn-symbols— 72 passed.cargo clippy --all-targets --features dyn-symbols -- -D warningsclean;cargo fmtclean.useKernel: true) against an Azure Databricks warehouse:SELECT 1authenticated by Entra ID with a JWT private-key client assertion, usingtokenUrlpointed at the Entra token endpoint. (See companion databricks-sql-nodejs PR.)This pull request and its description were written by Isaac.