Skip to content

[PECOBLR-3792] Add JWT private-key M2M authentication - #249

Merged
rahuls-db merged 1 commit into
mainfrom
feat/jwt-private-key-m2m
Aug 19, 2026
Merged

rahuls-db merged 1 commit into
mainfrom
feat/jwt-private-key-m2m

Conversation

@rahuls-db

@rahuls-db rahuls-db commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adds OAuth 2.0 machine-to-machine authentication using a JWT private-key client assertion (RFC 7523) instead of a client secret. Ported from the JDBC driver's JwtPrivateKeyClientCredentials. Resolves PECOBLR-3792.

The kernel signs a short-lived JWT with a PEM/PKCS#8 private key and sends it as the client_assertion in the client-credentials grant; the authorization server verifies it against the service principal's registered public key.

How

Kernel

  • AuthConfig::OAuthM2MPrivateKey variant + oauth_m2m_private_key constructor (config.rs)
  • JwtClientCredentialsProvider (auth/oauth/jwt_m2m.rs) — OIDC discovery, TokenStore lifecycle, and a manual client_assertion form POST. Reuses the existing M2M machinery; the only real delta vs. m2m.rs is sending a signed assertion instead of a secret (the oauth2 crate's exchange_client_credentials() can't send an assertion).
  • Key loading + signing (auth/oauth/jwt_key.rs) — PEM/PKCS#8 parsing, RSA + EC, unencrypted and PBES2 passphrase-encrypted keys, via jsonwebtoken + pkcs8.

Bindings

  • pyo3: Session(auth_type="oauth-m2m-jwt", jwt_key_file=…, jwt_kid=…, jwt_passphrase=…, jwt_algorithm=…)
  • napi: AuthMode.OAuthM2mJwt + jwtKeyFile/jwtKid/jwtPassphrase/jwtAlgorithm options

Dependencies

  • Runtime: jsonwebtoken (backed by ring, already in the graph via rustls — no new heavyweight dep) + pkcs8. No openssl.
  • Dev-only: rsa + p256 for in-process test-key generation.
  • No new licenses to allow-list — all new crates are MIT / Apache-2.0 / ISC, already in deny.toml.

Feature parity with JDBC

This ports JwtPrivateKeyClientCredentials + PrivateKeyClientCredentialProvider. The table below maps each JDBC capability to its kernel status.

Behavior parity

Capability JDBC Kernel Notes
client_credentials grant w/ JWT assertion ✅ ✅ client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
RFC 7523 claims (iss/sub=client_id, aud=token endpoint, jti, iat, exp) ✅ ✅ verified end-to-end in jwt_m2m_assertion_carries_rfc7523_claims
kid in JWT header ✅ ✅
RSA keys (RS256/384/512) ✅ ✅
RSA-PSS keys (PS256/384/512) ✅ ✅
EC keys (ES256, ES384) ✅ ✅
Default algorithm = RS256 ✅ ✅
Unencrypted PKCS#8 / PKCS#1 / SEC1 PEM ✅ ✅
Passphrase-encrypted PKCS#8 ✅ ⚠️ modern PBES2 only see Gap 2
OIDC token-endpoint discovery ✅ ✅ reuses OidcEndpoints::discover
Explicit token-endpoint override ✅ ✅ token_url / token_url_override
In-memory token caching + refresh ✅ ✅ reuses TokenStore (fresh/stale/expired state machine)
Configurable scopes (default all-apis) ✅ ✅
Key loaded/parsed once, cached ✅ ✅ parsed at construction

Intentional divergences (behavior deliberately differs)

  1. Unsupported algorithm → loud error, not silent RS256 fallback. JDBC's determineSignatureAlgorithm silently returns RS256 for any unrecognised algorithm (including ES512 and typos like HS256). The kernel instead returns a clear InvalidArgument at construction time listing the supported algorithms. Rationale: a silent fallback signs with the wrong algorithm and surfaces later as an opaque server-side invalid_client rejection with no hint at the real cause — strictly worse for the user. This is the one place we consciously do not match JDBC's behavior.

  2. JWT exp uses a small positive window, not exp == iat. JDBC sets the assertion's exp equal to its iat (a zero-length validity window that only works because servers tolerate clock skew — effectively a latent bug). The kernel gives the single-use assertion a short positive lifetime instead.

Gaps vs. JDBC (not supported)

  1. ES512 (P-521 curve). Not supported. ring (backing jsonwebtoken) has no P-521, and the only Rust path is the openssl crate — which would reintroduce the system-OpenSSL / Node-module-load clash the kernel deliberately eliminated (see the reqwest / [features] TLS notes in Cargo.toml). 8 of JDBC's 9 algorithms are covered; ES512 is rare in practice (RS256/ES256 dominate). Rejected loudly (see divergence 1) rather than silently mis-signed. A follow-up can evaluate a scoped P-521 path only if a customer needs it.

  2. Legacy encrypted-key schemes. Encrypted PKCS#8 support covers modern PBES2 (PBKDF2/scrypt + AES-CBC) — what current OpenSSL emits by default. Legacy schemes BouncyCastle also accepts (PBES1, 3DES-based encryption, PKCS#12-style) are not covered by the RustCrypto pkcs8 crate. Any key from roughly the last decade works; the fix for an older key is a one-line re-encrypt (openssl pkcs8 -topk8 -v2 aes-256-cbc) that the caller controls. Failure surfaces as a clear "Cannot decrypt private JWT key" error naming the unsupported scheme.

  3. authType() string. JDBC exposes "custom-oauth-m2m" via CredentialsProvider.authType(). N/A in the kernel — auth is selected by the AuthConfig enum variant, not a string, so there is nothing to match. (This is why JDBC's should_ReturnCorrectAuthType test has no kernel counterpart.)

Testing

Every JDBC test for this feature has a kernel equivalent except the N/A should_ReturnCorrectAuthType:

  • testDetermineSignatureAlgorithm → parse_algorithm_maps_supported_names / _defaults_to_rs256 / _rejects_es512_loudly / _rejects_unknown
  • testRetrieveToken → jwt_m2m_token_exchange_sends_assertion
  • testRetrieveTokenExceptionHandling → jwt_m2m_server_rejection_surfaces_error
  • testFetchSignedJWTWithRSAKey → jwt_m2m_assertion_carries_rfc7523_claims
  • should_FetchSignedJWT_WithECKey → loads_ec_p256_key_and_signs_es256
  • should_GetToken_UsesCache → jwt_m2m_caches_token_across_calls
  • should_ThrowException_When_ClientId/JwtKeyFile/JwtKidIsNull → oauth_m2m_private_key_rejects_missing_* (+ pyo3/napi binding equivalents)
  • should_HandleInvalidKeyFile → jwt_m2m_missing_key_file_fails
  • provider token-endpoint resolution tests → jwt_m2m_token_url_override_skips_discovery + discovery path in exchange tests

Plus kernel-only coverage JDBC lacks: loads_and_decrypts_pbes2_encrypted_key, wrong_passphrase_fails_with_clear_error, passphrase_on_unencrypted_key_is_rejected, ec_algorithm_with_rsa_key_fails.

Test keys are generated in-process (test_keys.rs) rather than committed as PEM fixtures — no secrets in the tree, no openssl CLI dependency. Green locally:

  • cargo test (kernel): 791 lib tests + all integration/doc tests
  • pyo3: 16 auth tests; napi: auth tests (--features dyn-symbols)
  • fmt + clippy -D warnings clean across all three crates

Error-message alignment: shared failure cases use JDBC's wording (Failed to parse private key, Cannot decrypt private JWT key, Failed to retrieve custom M2M token, Error signing the JWT); the two intentional divergences keep their own clearer messages.

End-to-end

Verified live against an Azure Databricks workspace. The kernel's OAuthM2MPrivateKey provider signs a client-assertion JWT with the service principal's private key, Entra ID verifies it against the public certificate registered on the app registration and issues a token, and that token authenticates a SQL session — SELECT 1 returns 1. Covered by the #[ignore]d jwt_m2m_select_one_round_trip test (v0_execute_e2e.rs), driven by DATABRICKS_JWT_* env vars.

This flow (RFC 7523 private_key_jwt) authenticates against the token endpoint of the workspace's configured OAuth IdP (Entra ID for Azure Databricks), not Databricks' native OIDC endpoint — matching the JDBC/Simba design (spec). The kernel points at the IdP via token_url (OIDC discovery otherwise), with the resource scope (<databricks-resource-id>/.default) supplied via DATABRICKS_JWT_SCOPES. Note: Entra identifies the signing cert by its SHA-1 thumbprint, so jwt_kid is that x5t value — the kernel passes it straight through the JWT header. (Databricks' AWS-native OIDC endpoints don't advertise private_key_jwt; this flow targets IdP-backed workspaces.)

Non-live coverage exercises the full path — key load → assertion signing → client-assertion token exchange → token parse — including cryptographic signature verification of the assertion against the public key (jwt_m2m_assertion_carries_rfc7523_claims) and a wiremock token-exchange round-trip.

Notes for reviewers

  • napi/index.d.ts was hand-edited (+23 lines) rather than fully regenerated, to avoid ~2700 lines of unrelated churn from a newer napi CLI version. I verified the JWT surface matches a real napi build byte-for-byte; index.js is untouched (no new top-level #[napi] exports).

This pull request and its description were written by Isaac.

@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 Medium

Solid, well-tested port of the JDBC JWT private-key M2M flow — key loading, algorithm validation, RFC 7523 claims, and token lifecycle all look correct and are covered by unit/wiremock tests. One medium efficiency concern: the client-assertion JWT is signed on every get_auth_header call (i.e. every HTTP request) even on the fresh-token fast path, rather than only when a token refresh occurs.

Comment thread src/auth/oauth/jwt_m2m.rs
// and `exp`.
let client_assertion = self.build_client_assertion()?;

let token = self.token_store.get_or_refresh(move || {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium — build_client_assertion() is invoked unconditionally at the top of get_auth_header, before TokenStore::get_or_refresh. Since auth_header() runs on every outbound request (http.rs:818, inside execute_impl), and get_or_refresh returns early on the FRESH fast path without ever calling the refresh closure, the common case signs a fresh JWT (RSA/EC signing) on every single request and then throws it away — the assertion is only actually consumed when a token refresh happens.

The m2m provider avoids any per-request crypto: it only clones strings up front and builds the OAuth client inside the refresh closure. The stated rationale here ("signing needs &self and can't move into the 'static closure") doesn't fully hold: signing_key is Arc<JwtSigningKey> and client_id/jwt_kid/token_endpoint are all cheaply cloneable, so the assertion could be built inside the closure (which already captures owned clones) and would then only be signed when a refresh actually runs. As written, every query pays an RSA signature it discards.

Consider moving the sign into the refresh closure (capturing Arc<JwtSigningKey> + the claim inputs) so signing happens only on the empty/expired/stale-refresh paths.

@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 Medium · 1 Low

Solid, well-tested port of the JDBC JWT private-key M2M flow; the auth wiring, config validation, redaction, and algorithm handling all look correct. Two non-blocking issues: a Medium unreachable error-handling block in jwt_m2m.rs (the manual !status.is_success() branch can never run because execute_without_auth already errors via ? on any non-2xx, so the intended JDBC-parity message and server body are never surfaced), and a Low note that the decrypted private-key PEM is not zeroized despite the repo's stated posture.

Comment thread src/auth/oauth/jwt_m2m.rs
),
("client_assertion", client_assertion),
];
if !scopes.is_empty() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium — This manual non-success branch is unreachable. execute_without_auth returns Ok(response) only when status.is_success() (http.rs:844 → return Ok(response) at 853); every non-2xx status falls through to the retryable-status check and then return Err(http_error(...)) at 914. Because the call one line above uses ?:

let response = http_client
    .execute_without_auth(request, RequestType::AuthTokenRequest)
    .await?;
let status = response.status();
if !status.is_success() { /* never runs */ }

response is guaranteed to be a success response, so !status.is_success() is always false. The consequences:

  • The // Mirror JDBC's "Failed to retrieve custom M2M token: …" comment is misleading — that message and the JDBC-parity .context("client credentials grant (jwt-bearer assertion)") never surface.
  • The server response body (e.g. {"error":"invalid_client","error_description":...}) that this block reads via response.text() is never included in the error; users see only the generic http_error produced inside execute_without_auth.

The test jwt_m2m_server_rejection_surfaces_error passes only because it accepts msg.contains("401"), which http_error already provides — it does not actually exercise this block. If you want the detailed body/JDBC wording, surface it from the execute_without_auth error path (or capture the body there); otherwise drop the dead block and its comment.

Comment thread src/auth/oauth/jwt_key.rs
)));
}

let encrypted = EncryptedPrivateKeyInfo::try_from(doc.as_bytes()).map_err(|e| {

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 decrypted private-key material is left in plaintext on the heap without zeroization. decrypt_pkcs8_pem re-encodes the decrypted key to an unencrypted PKCS#8 PEM String (decrypted.to_pem(...).map(|pem| pem.to_string())) and read_key_pem also holds the raw PEM String; both are dropped normally, leaving the private key sitting in freed heap memory. The repo already pulls in zeroize specifically to "Wipe derived key material on drop" (Cargo.toml:115), so this path is inconsistent with the established posture for sensitive key bytes. Consider wrapping the decrypted PEM in a zeroizing container (or explicitly zeroizing before drop) so the plaintext key does not linger. (Note: jsonwebtoken::EncodingKey itself does not zeroize, so this is partial hardening, but it removes the most obvious plaintext copy.)

@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 — a clean, well-tested port of JWT private-key M2M auth. Verified the token-exchange relies correctly on execute_without_auth's 2xx-only success contract, the rand/PKCS#8 usage matches existing crate patterns, and rsa/p256 are genuinely dev-only (absent from the napi/pyo3 lockfiles). One low-severity accuracy nit in the osv-scanner suppression wording.

Comment thread osv-scanner.toml
# like NotPresent and skips the check, letting an attacker bypass nbf/exp.
# Fixed in jsonwebtoken 10.3.0.
#
# Not reachable here: the kernel only SIGNS client assertions

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 suppression justification asserts "verified: no jsonwebtoken::decode / Validation calls anywhere in src/" (and the reason field repeats "never decodes/validates JWTs (verified: no decode/Validation calls in src/)"). This is inaccurate: the #[cfg(test)] module in src/auth/oauth/jwt_m2m.rs does call jsonwebtoken::decode, decode_header, and construct a Validation in jwt_m2m_assertion_carries_rfc7523_claims.

The substantive security claim still holds — the vulnerable code path is unreachable in the shipped artifact, since test code is never linked into the crate, and the decode there operates on self-generated tokens. But the literal "anywhere in src/" wording is what a future re-reviewer will grep against when ignoreUntil lapses, and that grep will hit the test usage and cast doubt on the audit trail. Suggest narrowing the wording to "no decode/Validation calls in non-test (shipped) code" or "in the runtime signing path" to keep the re-review check accurate.

@eric-wang-1990

Copy link
Copy Markdown
Collaborator

can you also add e2e testing details in the description i.e. can we connect with an actual workspace with private key attached to a service principal and verify this works.

Added an End-to-end subsection under Testing. Digging into this turned up a useful clarification about the flow itself:

This grant (RFC 7523 private_key_jwt, ported from JDBC's JwtPrivateKeyClientCredentials) authenticates against the workspace's configured OAuth IdP token endpoint, not Databricks' own OIDC endpoint. Per the internal Simba spec (Client Credentials Grant Support Enhancement in ODBC/JDBC), the working reference example posts the client_assertion to Entra ID (login.microsoftonline.com/.../oauth2/token), and the IdP verifies it against the cert registered on the app/SP there. So "private key attached to a service principal" means the public cert is registered on the IdP-side SP, and the kernel's token_url points at that IdP endpoint.

Verified empirically: the Databricks AWS-native OIDC endpoints (dogfood staging, benchmarking-prod) do not advertise private_key_jwt in token_endpoint_auth_methods_supported (only client_secret_* / none) and reject the assertion with "Client authentication method is not supported: private_key_jwt." An external IdP that supports the method (Entra, or Auth0's auth.bse.corp.databricks.com) accepts it.

So a live SELECT 1 needs an Entra-backed (Azure) workspace — or any workspace whose IdP supports private_key_jwt — with the SP cert registered on that IdP, run with token_url = the IdP token endpoint. I've added an #[ignore]d jwt_m2m_select_one_round_trip test (v0_execute_e2e.rs) wired for exactly this (it takes DATABRICKS_JWT_TOKEN_URL). Do you know of an Entra-backed test workspace + SP I can point it at? Happy to run it and paste the result.

Meanwhile the flow is fully covered by unit + wiremock tests, including cryptographic signature verification of the assertion against the public key and a wiremock token-exchange round-trip.

Do you just need an Azure workspace?
You can use our shared peco testing workspace: https://adb-6436897454825492.12.azuredatabricks.net/

@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: 2 Low

Solid, well-tested addition — the JWT private-key M2M flow closely mirrors the existing shared-secret M2M provider, correctly reuses TokenStore/OIDC machinery, redacts secrets in Debug, zeroizes key material, and validates the key/algorithm at construction. The token-endpoint error path correctly relies on execute_without_auth (verified: returns Err with status+body on non-2xx). Two low-severity audit-accuracy notes only: the osv-scanner suppression's "no decode/Validation in src/" claim is contradicted by the new test module, and the deny.toml rsa-advisory ignore is unconditionally global.

Comment thread osv-scanner.toml
# Fixed in jsonwebtoken 10.3.0.
#
# Not reachable here: the kernel only SIGNS client assertions
# (`jsonwebtoken::encode` in `src/auth/oauth/jwt_key.rs`) and never decodes

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 suppression justification asserts "verified: no jsonwebtoken::decode / Validation calls anywhere in src/", but this same PR adds a test in src/auth/oauth/jwt_m2m.rs (jwt_m2m_assertion_carries_rfc7523_claims) that does use jsonwebtoken::{decode, decode_header, Algorithm, DecodingKey, Validation}; and calls decode::<serde_json::Value>(...) with a Validation. The security conclusion is still sound — those calls are #[cfg(test)]-only and never ship, so the runtime genuinely only signs — but the literal claim is now false. A future re-reviewer (prompted by the ignoreUntil lapse) who greps src/ for decode/Validation to reconfirm will hit these test matches and be misled. Suggest narrowing the wording to "no decode/Validation calls in non-test (shipped) code" so the audit trail stays accurate.

Comment thread deny.toml
# We keep `rsa` (rather than dropping RSA test coverage for EC-only)
# because RS256 is the JDBC default and the most common real-world key
# type, so exercising the RSA load+sign path in tests has value.
# Re-evaluate when `rsa` ships a constant-time stable release.

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 RUSTSEC-2023-0071 (rsa Marvin attack) ignore is global by advisory ID — cargo-deny's [advisories].ignore has no per-package/dev-only scoping. The justification correctly notes rsa is dev-only today, but if a future change ever pulls rsa into the runtime graph (e.g. adopting a jsonwebtoken 10.x rust_crypto backend, exactly the path the Cargo.toml note contemplates), this entry will silently keep suppressing the advisory in shipped code, defeating the CI gate. Consider pairing the ignore with a [bans] deny that forbids rsa outside dev-dependencies, or at minimum note in the comment that the ignore is unconditional and must be removed the moment rsa moves to a runtime dep.

@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-tested port of JDBC's JWT private-key M2M flow. The new JwtClientCredentialsProvider correctly mirrors the existing m2m.rs lifecycle (verified TokenStore reuse, scope defaulting, and that execute_without_auth returns Ok only for 2xx so the token-exchange path needs no manual non-success branch). One low-severity note: the module documents SEC1/PKCS#1 PEM support but tests only exercise PKCS#8. Nit: the token-parse failure message in jwt_m2m.rs ("Failed to retrieve custom M2M token") reads like a copy leftover — the word "custom" doesn't correspond to anything user-facing.

Comment thread src/auth/oauth/jwt_key.rs
assert_eq!(header["alg"], "RS256");
assert_eq!(header["kid"], "my-kid");
}

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 module documents three unencrypted PEM formats as supported — PKCS#8 (BEGIN PRIVATE KEY), SEC1 EC (BEGIN EC PRIVATE KEY), and PKCS#1 RSA (BEGIN RSA PRIVATE KEY) — but test_keys only generates PKCS#8 (to_pkcs8_pem / SecretKey::to_pkcs8_pem). So build_encoding_key's from_ec_pem / from_rsa_pem paths are only ever exercised with PKCS#8 input. jsonwebtoken 9's from_ec_pem in particular is known to be picky about SEC1 vs PKCS#8 EC keys; if a user supplies an openssl-default BEGIN EC PRIVATE KEY (SEC1) the documented "handed directly" behavior is unverified and may fail. Consider adding a SEC1 EC and a PKCS#1 RSA fixture (both trivially derivable via to_sec1_pem / to_pkcs1_pem) to lock in the documented format coverage, or narrow the doc to the formats actually tested.

OAuth 2.0 machine-to-machine auth using a JWT private-key client
assertion (RFC 7523) instead of a client secret. The kernel signs a
short-lived JWT with a PEM/PKCS#8 private key (RSA or EC; unencrypted or
PBES2-encrypted) and sends it as the client_assertion in the
client-credentials grant; the IdP verifies it against the service
principal's registered public key. Ported from JDBC's
JwtPrivateKeyClientCredentials.

- Kernel: AuthConfig::OAuthM2MPrivateKey + oauth_m2m_private_key
  constructor; JwtClientCredentialsProvider (jwt_m2m.rs) reusing the
  M2M OIDC/TokenStore machinery; key loading + signing (jwt_key.rs)
- Parse the token response via oauth2::StandardTokenResponse
- Bindings: pyo3 auth_type="oauth-m2m-jwt", napi AuthMode.OAuthM2mJwt
- C ABI: kernel_session_config_set_auth_m2m_jwt (+ header, changelog)
- Telemetry: classify the variant as oauth-m2m-jwt / client-credentials
- Tests: unit + wiremock (incl. signature verification against the
  public key) and an ignored jwt_m2m_select_one_round_trip e2e verified
  live against an Azure Databricks warehouse via Entra ID

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 Medium

Looks good — a faithful, well-tested port of JDBC's JwtPrivateKeyClientCredentials. The manual client_assertion form POST matches the JDBC form (client_id intentionally omitted), the provider correctly reuses the existing TokenStore/OIDC lifecycle, secrets are redacted in Debug, and coverage is thorough across kernel/pyo3/napi/C-ABI. One medium: the napi binding can't override the token endpoint, which per the PR's own e2e notes blocks the Azure/Entra private_key_jwt case. Nits (not filed inline): decrypt_pkcs8_pem's error strings interpolate {e} with no separator after "key" (e.g. "Cannot decrypt private JWT key {e}"); and the h2/RUSTSEC-2026-0258 suppression is a pre-existing-on-main advisory unrelated to this change, bundled here — well-justified but worth landing separately if possible.

Comment thread napi/src/database.rs
options.jwt_passphrase.clone(),
options.jwt_algorithm.clone(),
options.oauth_scopes.clone(),
None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium — The napi OAuthM2mJwt arm hardcodes the token-endpoint override to None, and ConnectionOptions exposes no tokenUrl/jwtTokenUrl field, so Node consumers can only reach a token endpoint that OIDC discovery returns.

That's a functional gap specifically for this flow. Per this PR's own e2e docs (live_jwt_session, tests/v0_execute_e2e.rs:56-60), the Databricks AWS-native OIDC endpoint does not advertise private_key_jwt; Azure/Entra workspaces require pointing the token endpoint at the IdP directly (DATABRICKS_JWT_TOKEN_URL). The pyo3 binding (pyo3/src/auth.rs, forwards oauth.token_url) and the C ABI (kernel_session_config_set_auth_m2m_jwt's token_url) both expose this override; only napi omits it, leaving Node users unable to use JWT M2M against the very IdPs the feature targets.

It is consistent with napi's existing client-secret M2M (also no token_url), but client-secret M2M works via discovery whereas private_key_jwt frequently cannot — so the omission bites harder here. Consider adding a jwtTokenUrl (or general tokenUrl) option and threading it into this arm.

@rahuls-db

Copy link
Copy Markdown
Collaborator Author

/merge

This branch was previously deployed

1 inactive deployment
azure-prod — ffdc37c4 Deployed Aug 19, 2026 by oss-reviewer-bot[bot] via followup #716
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.

3 participants