Skip to content

feat(bindings): thread Azure service-principal M2M through the napi + C ABI bindings - #280

Merged
eric-wang-1990 merged 2 commits into
eric-wang/azure-service-principal-designfrom
eric-wang/napi-azure-sp-m2m
Aug 21, 2026
Merged

eric-wang-1990 merged 2 commits into
eric-wang/azure-service-principal-designfrom
eric-wang/napi-azure-sp-m2m

Conversation

@eric-wang-1990

@eric-wang-1990 eric-wang-1990 commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

Threads Azure Entra service-principal M2M through the napi (Node.js) and C ABI (Go / ODBC) bindings — the analogs of the pyo3 auth_type="azure-sp-m2m" surface that #263 added for Python. #263 wired azure-sp-m2m through pyo3 + the core AuthConfig, but left the other two bindings untouched.

Stacked on #263 — targets eric-wang/azure-service-principal-design because it calls AuthConfig::azure_service_principal, which lives in #263, not main. Rebase onto main once #263 merges.

How

napi (napi/src/database.rs, napi/index.d.ts):

  • New AuthMode::AzureSpM2m + ConnectionOptions fields azureClientId / azureClientSecret (required), azureTenantId?, azureWorkspaceResourceId?.
  • build_auth_config arm → AuthConfig::azure_service_principal(...). index.d.ts regenerated to match.

C ABI (src/c_abi/session.rs, include/databricks_kernel.h):

  • New kernel_session_config_set_auth_azure_sp(config, azure_client_id, azure_client_secret, azure_tenant_id, azure_workspace_resource_id) alongside set_auth_pat / _m2m / _m2m_jwt / _u2m.
  • New AuthSpec::AzureServicePrincipal variant + conversion to AuthConfig::azure_service_principal (carrying the shared federation client id). Hand-written header declaration added.

Common semantics across both: azureClientId + azureClientSecret required; azureTenantId optional (kernel auto-discovers from the workspace /aad/auth redirect when omitted); azureWorkspaceResourceId optional (set ⇒ the kernel also sends the Azure SP management token + X-Databricks-Azure-Workspace-Resource-Id header, for an SP with an Azure RBAC role but no workspace membership; omitted ⇒ the data token authenticates alone). The bindings stay thin — the kernel owns all Azure resolution (Entra token endpoint, {app}/.default scope, tenant discovery, and the management token's v1.0 resource= grant).

Azure AD U2M needs no new mode/setter on either binding — it rides the existing napi AuthMode::OAuthU2m / C-ABI set_auth_u2m, i.e. the kernel's in-house workspace-federated browser flow, which Azure Databricks workspaces support. The connectors map their Azure-U2M selectors onto that (separate connector-repo PRs).

Tests

  • napi (cargo test --features dyn-symbols): azure_sp_m2m_builds_azure_service_principal, azure_sp_m2m_tenant_and_resource_id_optional, azure_sp_m2m_requires_client_id_and_secret.
  • C ABI (cargo test): azure_sp_builds_azure_service_principal (incl. federation id passthrough), azure_sp_tenant_and_resource_id_optional.
  • All green; clippy -D warnings clean; napi loader drift check passes; TDD throughout (stub → RED → real arm → GREEN on both bindings).

Related

This pull request and its description were written by Isaac.

…he binding

Add AuthMode::AzureSpM2m to the napi binding, mirroring the pyo3
auth_type="azure-sp-m2m" surface added for Python. New ConnectionOptions
fields: azureClientId + azureClientSecret (required), plus optional
azureTenantId (kernel auto-discovers from the workspace /aad/auth redirect
when omitted) and azureWorkspaceResourceId (when set, the kernel also sends
the Azure SP management token + X-Databricks-Azure-Workspace-Resource-Id
header, so an SP with an Azure RBAC role but no workspace membership can
authenticate). The build_auth_config arm forwards to the kernel's
AuthConfig::azure_service_principal; the kernel owns Azure resolution.

Azure AD U2M needs no new mode — it rides the existing AuthMode::OAuthU2m
(the kernel's workspace-federated browser flow, which Azure workspaces
support). Regenerated napi/index.d.ts to match.

Stacked on the pyo3/core azure-sp-m2m PR (#263), which is where
AuthConfig::azure_service_principal lives.

Co-authored-by: Isaac
Signed-off-by: eric-wang-1990 <e.wang@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.

✅ No issues identified by the review bot.

…or Go/ODBC

Add kernel_session_config_set_auth_azure_sp to the C ABI, so Go/ODBC
consumers can use Azure Entra service-principal M2M — the C-ABI analog of the
pyo3/napi azure-sp-m2m surface. Required azure_client_id + azure_client_secret;
optional azure_tenant_id (NULL -> kernel auto-discovers from the workspace
/aad/auth redirect) and azure_workspace_resource_id (set -> kernel also sends
the Azure SP management token + X-Databricks-Azure-Workspace-Resource-Id
header, for an SP with an Azure RBAC role but no workspace membership).

New AuthSpec::AzureServicePrincipal variant + conversion to
AuthConfig::azure_service_principal (carrying the shared federation client id).
Hand-written header declaration added. Azure AD U2M needs no new setter — it
rides set_auth_u2m (the kernel's workspace-federated browser flow, which Azure
Databricks workspaces support).

Co-authored-by: Isaac
Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
@eric-wang-1990 eric-wang-1990 changed the title feat(napi): thread Azure service-principal M2M (AzureSpM2m) through the Node.js binding feat(bindings): thread Azure service-principal M2M through the napi + C ABI bindings Aug 21, 2026

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

✅ No issues identified by the review bot.

@eric-wang-1990
eric-wang-1990 merged commit 53fc45e into eric-wang/azure-service-principal-design Aug 21, 2026
8 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — 1495174d Deployed Aug 21, 2026 by eric-wang-1990 via review #360
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