From 68ed5d5499db73e6ff50942ac646a5fa226d835f Mon Sep 17 00:00:00 2001 From: Rahul Singhal Date: Wed, 19 Aug 2026 23:54:05 +0000 Subject: [PATCH 1/2] feat(napi): expose token_url for M2M / JWT client-assertion auth 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 --- napi/NEXT_CHANGELOG.md | 7 +++++++ napi/index.d.ts | 9 +++++++++ napi/src/database.rs | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/napi/NEXT_CHANGELOG.md b/napi/NEXT_CHANGELOG.md index 58da3936..feb2302e 100644 --- a/napi/NEXT_CHANGELOG.md +++ b/napi/NEXT_CHANGELOG.md @@ -20,6 +20,13 @@ layout, or npm publishing. Pure-kernel changes go in the root encrypted PKCS#8 keys), and `jwtAlgorithm` (optional, default `RS256`), alongside the existing `oauthClientId` / `oauthScopes`. Forwards to the kernel's `AuthConfig::OAuthM2MPrivateKey`. +- `ConnectionOptions.tokenUrl` — OAuth token endpoint override. When omitted the + kernel discovers the endpoint via the workspace's OIDC configuration; set it to + point the client-credentials / JWT client-assertion grant at the workspace's + configured IdP token endpoint (e.g. Entra ID for Azure Databricks). Required for + `AuthMode.OAuthM2mJwt` against an external-IdP-backed workspace, since + Databricks-native OIDC does not advertise the `private_key_jwt` method. Applies to + `AuthMode.OAuthM2m` too. Forwards to the kernel's `token_url_override`. - `ConnectionOptions.identityFederationClientId` selects SP-wide Workload Identity Federation during mandatory token exchange. diff --git a/napi/index.d.ts b/napi/index.d.ts index bf15780b..4da03ecd 100644 --- a/napi/index.d.ts +++ b/napi/index.d.ts @@ -210,6 +210,15 @@ export interface ConnectionOptions { * (`["all-apis"]` for M2M; `["sql", "offline_access"]` for U2M). */ oauthScopes?: Array + /** + * OAuth token endpoint override. When omitted the kernel discovers the + * endpoint via the workspace's OIDC configuration. Set it to point the + * client-credentials / JWT client-assertion grant at the workspace's + * configured IdP token endpoint (e.g. Entra ID for Azure Databricks), + * which is required when that IdP — not Databricks-native OIDC — is the + * authority for [`AuthMode::OAuthM2m`] / [`AuthMode::OAuthM2mJwt`]. + */ + tokenUrl?: string /** * Path to the PEM private-key file. Required for * [`AuthMode::OAuthM2mJwt`]. diff --git a/napi/src/database.rs b/napi/src/database.rs index b9791350..48197ebd 100644 --- a/napi/src/database.rs +++ b/napi/src/database.rs @@ -160,6 +160,13 @@ pub struct ConnectionOptions { /// OAuth scopes override (M2M / U2M). Omitted ⇒ kernel defaults /// (`["all-apis"]` for M2M; `["sql", "offline_access"]` for U2M). pub oauth_scopes: Option>, + /// OAuth token endpoint override. When omitted the kernel discovers the + /// endpoint via the workspace's OIDC configuration. Set it to point the + /// client-credentials / JWT client-assertion grant at the workspace's + /// configured IdP token endpoint (e.g. Entra ID for Azure Databricks), + /// which is required when that IdP — not Databricks-native OIDC — is the + /// authority for [`AuthMode::OAuthM2m`] / [`AuthMode::OAuthM2mJwt`]. + pub token_url: Option, /// Path to the PEM private-key file. Required for /// [`AuthMode::OAuthM2mJwt`]. pub jwt_key_file: Option, @@ -361,7 +368,7 @@ fn build_auth_config(options: &ConnectionOptions) -> napi::Result { options.oauth_client_id.clone(), options.oauth_client_secret.clone(), options.oauth_scopes.clone(), - None, + options.token_url.clone(), options.identity_federation_client_id.clone(), ) .map_err(napi_err_from_kernel), @@ -376,7 +383,7 @@ fn build_auth_config(options: &ConnectionOptions) -> napi::Result { options.jwt_passphrase.clone(), options.jwt_algorithm.clone(), options.oauth_scopes.clone(), - None, + options.token_url.clone(), ) .map_err(napi_err_from_kernel), // napi injects no client_id/scope default: it rides the kernel's @@ -632,6 +639,7 @@ mod tests { oauth_client_secret: None, oauth_redirect_port: None, oauth_scopes: None, + token_url: None, jwt_key_file: None, jwt_kid: None, jwt_passphrase: None, @@ -765,6 +773,7 @@ mod tests { o.jwt_passphrase = Some("pass".to_owned()); o.jwt_algorithm = Some("ES256".to_owned()); o.oauth_scopes = Some(vec!["all-apis".to_owned()]); + o.token_url = Some("https://idp.example/token".to_owned()); match build_auth_config(&o).unwrap() { AuthConfig::OAuthM2MPrivateKey { client_id, @@ -773,6 +782,7 @@ mod tests { jwt_passphrase, jwt_algorithm, scopes, + token_url_override, .. } => { assert_eq!(client_id, "cid"); @@ -781,6 +791,7 @@ mod tests { assert_eq!(jwt_passphrase.as_deref(), Some("pass")); assert_eq!(jwt_algorithm.as_deref(), Some("ES256")); assert_eq!(scopes, Some(vec!["all-apis".to_owned()])); + assert_eq!(token_url_override.as_deref(), Some("https://idp.example/token")); } other => panic!("expected OAuthM2MPrivateKey, got {other:?}"), } From 4d6510941ab9a43a2d691e4f8ccb53f0ba8b4e36 Mon Sep 17 00:00:00 2001 From: Rahul Singhal Date: Thu, 20 Aug 2026 00:03:10 +0000 Subject: [PATCH 2/2] style(napi): reflow token_url test assert to satisfy CI rustfmt 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 --- napi/src/database.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/napi/src/database.rs b/napi/src/database.rs index 48197ebd..96c946b6 100644 --- a/napi/src/database.rs +++ b/napi/src/database.rs @@ -773,7 +773,8 @@ mod tests { o.jwt_passphrase = Some("pass".to_owned()); o.jwt_algorithm = Some("ES256".to_owned()); o.oauth_scopes = Some(vec!["all-apis".to_owned()]); - o.token_url = Some("https://idp.example/token".to_owned()); + let token_url = "https://idp.example/token"; + o.token_url = Some(token_url.to_owned()); match build_auth_config(&o).unwrap() { AuthConfig::OAuthM2MPrivateKey { client_id, @@ -791,7 +792,7 @@ mod tests { assert_eq!(jwt_passphrase.as_deref(), Some("pass")); assert_eq!(jwt_algorithm.as_deref(), Some("ES256")); assert_eq!(scopes, Some(vec!["all-apis".to_owned()])); - assert_eq!(token_url_override.as_deref(), Some("https://idp.example/token")); + assert_eq!(token_url_override.as_deref(), Some(token_url)); } other => panic!("expected OAuthM2MPrivateKey, got {other:?}"), }