Add default passphrase support#19360
Conversation
Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
There was a problem hiding this comment.
Pull request overview
This PR adds default KEK (Key Encryption Key) passphrase support for the MLflow gateway secrets feature, enabling a non-disruptive getting started experience for development and single-user scenarios. The default passphrase is automatically used when MLFLOW_CRYPTO_KEK_PASSPHRASE is not set, and a new API endpoint exposes whether the server is using the default passphrase to allow the UI to display appropriate warnings.
Key changes:
- Introduces a default passphrase constant for development/testing environments with comprehensive security warnings
- Adds a
using_default_passphraseproperty toKEKManagerto track passphrase source - Exposes passphrase status via new
/ajax-api/3.0/mlflow/secrets/configendpoint returning JSON withsecrets_availableandusing_default_passphraseflags
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| mlflow/utils/crypto.py | Implements default passphrase fallback in KEKManager, adds using_default_passphrase property, and improves decryption error messages to help users diagnose passphrase mismatches |
| mlflow/server/handlers.py | Adds new _get_secrets_config endpoint handler and registers it in gateway endpoints list |
| tests/utils/test_crypto.py | Updates tests to verify default passphrase behavior instead of expecting exceptions, adds test for custom passphrase flag |
| tests/tracking/test_rest_tracking.py | Adds integration tests for the new secrets config endpoint covering both custom and default passphrase scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Documentation preview for d626d6e is available at: More info
|
mlflow/utils/crypto.py
Outdated
| passphrase = DEFAULT_KEK_PASSPHRASE | ||
| _logger.warning( | ||
| "MLFLOW_CRYPTO_KEK_PASSPHRASE not set. Using default passphrase for " | ||
| "secrets encryption. This is acceptable for development/testing but " |
There was a problem hiding this comment.
Shall we explicitly tell what kind of case is risky? Here I think development/testing refers to localhost tracking server and production refer to remove tracking server (or tracking server with public hostname), correct? Even for users who share a remote tracking server among multiple team members for agent development, we want them to set MLFLOW_CRYPTO_KEK_PASSPHRASE
There was a problem hiding this comment.
Great call out! I'll add additional details to specify where this is a security flaw and where it doesn't really matter.
tests/tracking/test_rest_tracking.py
Outdated
|
|
||
|
|
||
| def test_get_secrets_config_with_custom_passphrase(mlflow_client_with_secrets): | ||
| import requests |
There was a problem hiding this comment.
requests is imported on the top of this file
tests/tracking/test_rest_tracking.py
Outdated
| import requests | ||
|
|
||
| from mlflow.server import handlers | ||
| from mlflow.server.fastapi_app import app | ||
| from mlflow.server.handlers import initialize_backend_stores | ||
| from mlflow.store.tracking.sqlalchemy_store import SqlAlchemyStore | ||
|
|
||
| from tests.tracking.integration_test_utils import ServerThread, get_safe_port | ||
|
|
There was a problem hiding this comment.
can we import packages on the module level where possible?
TomeHirata
left a comment
There was a problem hiding this comment.
Overall looks good to me, left some comments on warning message and test style
Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
Signed-off-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
|
GenAI test failure is being addressed in #19407; windows failure is unrelated. |
Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com> Signed-off-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com> Signed-off-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
🛠 DevTools 🛠
Install mlflow from this PR
For Databricks, use the following command:
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
This PR adds a default KEK (Key Encryption Key) passphrase for the gateway secrets feature and exposes this information via an ajax server-side-only API endpoint so the frontend can warn users when they're using the default passphrase.
This allows for a non-disruptive getting started scenario or for a single-user to utilize AI Gateway if high security is not a major concern. The addition of the flag to the endpoint will be used for notifications in the UI (fetched during main landing page load).
GET /ajax-api/3.0/mlflow/secrets/config
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow 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" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.