Repository navigation
feat(napi): expose kernel OAuth (M2M + U2M) on openSession ConnectionOptions - #95
Closed
msrathore-db wants to merge 1 commit into
Closed
msrathore-db wants to merge 1 commit into
msrathore-db wants to merge 1 commit into
Conversation
Collaborator
|
Mismatched fields are silently ignored (build_auth_config, diff:101-126)
Empty oauth_scopes not normalized to None (diff:113, 121)
Empty-string oauthClientId on U2M bypasses kernel default (diff:119)
Test coverage gaps on boundary conditions (diff:162-260)
|
…Options
The kernel implements OAuth M2M (client-credentials) and U2M (auth-code +
PKCE) in `AuthConfig::OAuthM2M` / `OAuthU2M`, but the napi binding only
wired `AuthConfig::Pat` — so NodeJS SEA (and pyo3, which has the same gap)
could not offer OAuth even though the kernel fully supports it. This
surfaces it on the binding.
- New `#[napi(string_enum)] AuthMode { Pat, OAuthM2m, OAuthU2m }` whose
string values (`'Pat'` / `'OAuthM2m'` / `'OAuthU2m'`) match what the
NodeJS SEA adapter (`SeaAuth`) already expects verbatim.
- `ConnectionOptions` gains `authMode` (default Pat — back-compat for
existing PAT callers that pass only `token`), `oauthClientId`,
`oauthClientSecret`, `oauthRedirectPort`, `oauthScopes`. `token` is now
optional (required only for Pat).
- `build_auth_config` maps the JS options onto the kernel `AuthConfig`,
enforcing per-mode required fields at the binding boundary (fail-fast
`InvalidArgument` before any network) so the kernel always receives a
fully-formed variant. Pure + unit-tested. OAuth `Federation` / `External`
are intentionally not exposed (kernel marks federation unimplemented;
External is a Rust-trait escape hatch with no JS-callback bridge).
Validation: cargo fmt + clippy clean; 4 new unit tests (Pat default +
empty-token reject, M2M required-field validation, U2M all-optional with
override threading); 41 napi unit tests green. Live: OAuth M2M
client-credentials grant against pecotesting authenticated successfully
(server then applied warehouse-level authorization); PAT continues to work
both with an explicit `authMode: Pat` and with `authMode` omitted.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
force-pushed
the
msrathore/krn-napi-oauth
branch
from
May 31, 2026 10:46
052bb96 to
f34cc9d
Compare
This was referenced May 31, 2026
Collaborator
Author
|
Closing as superseded by #101, which is now the main-based kernel SEA parity mega PR for agent review. The branch is preserved and this can be reopened if we decide to return to smaller stacked reviews. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The kernel fully implements OAuth M2M (client-credentials) and U2M (auth-code + PKCE) in
AuthConfig::OAuthM2M/OAuthU2M, but the napi binding only wiredAuthConfig::Pat. So NodeJS SEA — and pyo3, which has the identical gap — could not offer OAuth despite the kernel supporting it. This surfaces it on the binding.Changes
#[napi(string_enum)] AuthMode { Pat, OAuthM2m, OAuthU2m }— string values ('Pat'/'OAuthM2m'/'OAuthU2m') match what the NodeJS SEA adapter (SeaAuth) already expects verbatim, so the Node side wires straight onto it.ConnectionOptionsgainsauthMode(defaultPat— back-compat for existing PAT callers),oauthClientId,oauthClientSecret,oauthRedirectPort,oauthScopes;tokenbecomes optional (required only forPat).build_auth_configmaps the JS options onto the kernelAuthConfig, enforcing per-mode required fields at the binding boundary (fail-fastInvalidArgumentbefore any network). Pure + unit-tested.OAuthFederation/Externalintentionally not exposed (kernel marks federation unimplemented;Externalis a Rust-trait escape hatch with no JS-callback bridge).Layering / DRY
Auth logic stays in the kernel (
AuthConfig+ the OAuth flows); the binding only validates the JS option shape and selects the variant. The NodeJS SEA adapter maps its publicauthType: 'databricks-oauth'→authMode+ the OAuth fields.Validation
cargo fmt+cargo clippy --libclean; 4 new unit tests (Pat default + empty-token reject, M2M required-field validation, U2M all-optional + override threading); 41 napi unit tests green.403 PERMISSION_DENIEDfor an SPN not granted on that warehouse; a401would indicate a failed token exchange). PAT continues to work both with an explicitauthMode: Patand withauthModeomitted.This pull request and its description were written by Isaac.