Skip to content

[TypeScript SDK] Simplify Databricks auth by delegating to Databricks SDK#19434

Merged
B-Step62 merged 6 commits intomlflow:masterfrom
simonfaltum:simonfaltum/js-lib-dbx-auth
Dec 22, 2025
Merged

[TypeScript SDK] Simplify Databricks auth by delegating to Databricks SDK#19434
B-Step62 merged 6 commits intomlflow:masterfrom
simonfaltum:simonfaltum/js-lib-dbx-auth

Conversation

@simonfaltum
Copy link
Contributor

@simonfaltum simonfaltum commented Dec 16, 2025

What changes are proposed in this pull request?

This PR adds a new authentication module to the MLflow TypeScript SDK that provides flexible authentication for both self-hosted MLflow servers and managed MLflow services.

Key Changes:

  1. New auth module (libs/typescript/core/src/auth/index.ts)

    • Provides AuthProvider interface with sync getHost() and async getHeadersProvider()
    • Supports basic auth (username/password) and bearer token authentication
    • Clean separation of authentication concerns from client code
  2. Updated artifacts clients

    • Both DatabricksArtifactsClient and MlflowArtifactsClient now use AuthProvider pattern
    • Legacy databricksToken parameter kept for backwards compatibility
  3. Documentation

    • Added authentication section to README for self-hosted MLflow servers

This change is fully backwards compatible.

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

All 172 tests pass, including new tests for authentication configuration.

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Updated libs/typescript/README.md with authentication documentation for self-hosted MLflow servers.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

The TypeScript SDK now has a dedicated authentication module supporting basic auth and bearer token authentication for MLflow tracking servers.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

@github-actions
Copy link
Contributor

@simonfaltum Thank you for the contribution! Could you fix the following issue(s)?

⚠ DCO check

The DCO check failed. Please sign off your commit(s) by following the instructions here. See https://github.com/mlflow/mlflow/blob/master/CONTRIBUTING.md#sign-your-work for more details.

⚠ Invalid PR template

This PR does not appear to have been filed using the MLflow PR template. Please copy the PR template from here and fill it out.

@simonfaltum simonfaltum force-pushed the simonfaltum/js-lib-dbx-auth branch 2 times, most recently from 0280d74 to ef3a52a Compare December 16, 2025 15:20
@github-actions github-actions bot added area/docs Documentation issues area/tracing MLflow Tracing and its integrations area/tracking Tracking service, tracking client APIs, autologging rn/feature Mention under Features in Changelogs. labels Dec 16, 2025
… SDK

- Add new auth module that delegates credential resolution to @databricks/sdk
- Require DATABRICKS_HOST env var for Databricks connections (enables sync host resolution)
- SDK handles PAT tokens, OAuth M2M, Azure/GCP credentials, and config profiles
- Support OSS MLflow auth via basic auth or bearer token
- Update artifacts clients to use AuthProvider pattern
- Add authentication documentation to README

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: simon <simon.faltum@databricks.com>
@simonfaltum simonfaltum force-pushed the simonfaltum/js-lib-dbx-auth branch from ef3a52a to da8c3cb Compare December 16, 2025 15:32
MlflowClient and ArtifactsClient are internal APIs, so this removes
backwards-compatibility options that are no longer needed:

- Remove deprecated host, databricksToken, and tracking server credentials
  from MlflowClientOptions and ArtifactsClientOptions
- Make authProvider a required parameter
- Remove unused getRequestHeaders helper from utils.ts
- Move base64 auth header encoding outside function scope for efficiency
- Update provider.ts to use getAuthProvider() from config
- Remove deprecated resolveAuthProvider alias

This reduces code duplication by centralizing auth handling in the
createAuthProvider function, which consumers should use to create
an AuthProvider before passing it to these clients.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: simon <simon.faltum@databricks.com>
host: string;
databricksToken?: string;
}): ArtifactsClient {
export function getArtifactsClient(options: ArtifactsClientOptions): ArtifactsClient {
Copy link
Collaborator

@TomeHirata TomeHirata Dec 17, 2025

Choose a reason for hiding this comment

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

Let's keep using destructuring assignment. We can use destructuring assignment and interface together.

private headersProvider: HeadersProvider;

constructor(options: { host: string }) {
constructor(options: MlflowArtifactsClientOptions) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

*
* @param options - Client configuration options
*/
constructor(options: MlflowClientOptions) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

Comment on lines +230 to +234
const result: Record<string, string> = {};
headers.forEach((value, key) => {
result[key] = value;
});
return result;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use Object.fromEntries(headers)?

Copy link
Collaborator

@TomeHirata TomeHirata left a comment

Choose a reason for hiding this comment

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

Left some comments, otherwise LGTM!

Comment on lines +127 to +128
const headers = await this.headersProvider();
const response = await makeRequest<CreateExperiment.Response>('POST', url, headers, payload);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i wonder if it's worth defining some request helper on the class so we don't have to remember to call const headers = await this.headersProvider(); and pass it in to every request

Copy link
Collaborator

Choose a reason for hiding this comment

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

not a big deal for now as i guess we don't plan to add many more request types but just thinking for the future

Copy link
Collaborator

@B-Step62 B-Step62 Dec 22, 2025

Choose a reason for hiding this comment

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

Great idea, I think we can replace headers with headersProvider in makeRequest to prevent such mistakes.

Copy link
Collaborator

@daniellok-db daniellok-db left a comment

Choose a reason for hiding this comment

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

lg overall, thanks for making this change!

@B-Step62 B-Step62 linked an issue Dec 19, 2025 that may be closed by this pull request
14 tasks
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
@B-Step62 B-Step62 added this pull request to the merge queue Dec 22, 2025
Merged via the queue into mlflow:master with commit 1caf293 Dec 22, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation issues area/tracing MLflow Tracing and its integrations area/tracking Tracking service, tracking client APIs, autologging rn/feature Mention under Features in Changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Support Databricks config file with Client ID and Client Secret

4 participants