-
Notifications
You must be signed in to change notification settings - Fork 51
feat(kernel): support static token federation #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
753609d
f26244c
b2016b7
376cc0e
b23baa6
1f66bf1
7e5c268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0d46716c466897148dfc1d2976ff03bdf097998c | ||
| eff8950428f4e6cc9975c663ec919f334962f7d0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,10 @@ const DEFAULT_OAUTH_CLIENT_ID = 'databricks-sql-connector'; | |
| * everything else (client_id, scopes, callback timeout, | ||
| * token_url_override) uses kernel defaults. | ||
| * | ||
| * `static-token` reuses the native PAT bearer-token mode, where federation is | ||
| * always enabled. `enableTokenFederation` is ignored; a non-empty | ||
| * `federationClientId` selects SP-wide WIF and omission selects account-wide. | ||
| * | ||
| * The `authMode` string literals MUST match the napi-emitted `AuthMode` | ||
| * variant names verbatim (`'Pat'`, `'OAuthM2m'`, `'OAuthU2m'` — napi-rs's | ||
| * `#[napi(string_enum)]` without an explicit case option emits the | ||
|
|
@@ -212,10 +216,19 @@ export interface KernelProxyOptions { | |
| }; | ||
| } | ||
|
|
||
| export interface KernelFederationOptions { | ||
| /** | ||
| * SP-wide Workload Identity Federation client id. Omitted selects BYOT / | ||
| * account-wide WIF. | ||
| */ | ||
| identityFederationClientId?: string; | ||
| } | ||
|
|
||
| export type KernelNativeConnectionOptions = KernelSessionDefaults & | ||
| KernelTlsOptions & | ||
| KernelHttpOptions & | ||
| KernelProxyOptions & | ||
| KernelFederationOptions & | ||
| ( | ||
| | { | ||
| hostName: string; | ||
|
|
@@ -443,6 +456,10 @@ export function buildKernelHttpOptions(options: ConnectionOptions): KernelHttpOp | |
| * - PAT: `authType: 'access-token'` (or undefined, which already means | ||
| * PAT throughout the existing driver — see | ||
| * `DBSQLClient.createAuthProvider`). | ||
| * - Static token: `authType: 'static-token'` + `staticToken`. The token is | ||
| * forwarded through the native PAT bearer-token mode, where federation is | ||
| * always enabled. `federationClientId` selects SP-wide WIF; omission | ||
| * selects account-wide WIF. `enableTokenFederation` is ignored. | ||
| * - OAuth M2M: `authType: 'databricks-oauth'` + `oauthClientId` + | ||
| * `oauthClientSecret`. Kernel handles OIDC discovery, client_credentials | ||
| * exchange, and re-auth on expiry internally. | ||
|
|
@@ -556,7 +573,8 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel | |
| maxConnections?: number; | ||
| } & KernelTlsOptions & | ||
| KernelHttpOptions & | ||
| KernelProxyOptions = { | ||
| KernelProxyOptions & | ||
| KernelFederationOptions = { | ||
| hostName: options.host, | ||
| httpPath: prependSlash(options.path), | ||
| // Match the NodeJS Thrift driver, which surfaces INTERVAL columns as | ||
|
|
@@ -621,6 +639,26 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel | |
| return { ...base, authMode: 'Pat', token }; | ||
| } | ||
|
|
||
| if (authType === 'static-token') { | ||
| const { staticToken, federationClientId } = options as { | ||
| staticToken?: string; | ||
| federationClientId?: string; | ||
| }; | ||
| if (typeof staticToken !== 'string' || isBlankOrReserved(staticToken)) { | ||
| throw new AuthenticationError( | ||
| "kernel backend: a non-empty token must be supplied via `staticToken` when using `authType: 'static-token'`.", | ||
| ); | ||
| } | ||
| if (oauth.oauthClientId !== undefined || oauth.oauthClientSecret !== undefined) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — The This matters most for a user migrating from PAT who leaves |
||
| throw new HiveDriverError( | ||
| 'kernel backend: cannot supply `staticToken` alongside `oauthClientId`/`oauthClientSecret` ' + | ||
| 'on the same connection. Pick one auth mode.', | ||
| ); | ||
| } | ||
| base.identityFederationClientId = federationClientId || undefined; | ||
| return { ...base, authMode: 'Pat', token: staticToken }; | ||
| } | ||
|
|
||
| if (authType === 'databricks-oauth') { | ||
| if ((options as { token?: string }).token !== undefined) { | ||
| throw new HiveDriverError( | ||
|
|
@@ -694,7 +732,7 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel | |
|
|
||
| throw new HiveDriverError( | ||
| `kernel backend: unsupported auth mode '${authType}'. ` + | ||
| "Supported modes on the kernel backend today: 'access-token' (PAT) and 'databricks-oauth' " + | ||
| "Supported modes on the kernel backend today: 'access-token' (PAT), 'static-token', and 'databricks-oauth' " + | ||
| '(M2M with oauthClientId+oauthClientSecret, or U2M with neither).', | ||
| ); | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.