The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Litellm encrypt admin UI values (#12675)
Krish Dholakiab515d051ff67
diff --git a/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py b/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.pyindex 16959f88f02..415ec923c41 100644--- a/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py+++ b/litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py@@ -471,6 +471,7 @@ async def update_sso_settings(sso_config: SSOConfig):# Update environment variables in config and in memorysso_data = sso_config.model_dump(exclude_none=True)+ mapped_env_vars = {}for field_name, value in sso_data.items():if field_name == "user_email" and value is not None:@@ -483,11 +484,17 @@ async def update_sso_settings(sso_config: SSOConfig):env_var_name = env_var_mapping[field_name]# Update in configconfig["environment_variables"][env_var_name] = value+ mapped_env_vars[env_var_name] = value# Update in runtime environmentos.environ[env_var_name] = value+ stored_config = config+ if len(mapped_env_vars) > 0:+ stored_config["environment_variables"] = proxy_config._encrypt_env_variables(+ environment_variables=mapped_env_vars+ )# Save the updated config- await proxy_config.save_config(new_config=config)+ await proxy_config.save_config(new_config=stored_config)return {"message": "SSO settings updated successfully",diff --git a/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py b/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.pyindex 98dbb589efd..395f12ca111 100644--- a/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py+++ b/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py@@ -267,7 +267,8 @@ class TestProxySettingEndpoints:assert "google_client_id" in data["field_schema"]["properties"]assert "description" in data["field_schema"]["properties"]["google_client_id"]- def test_update_sso_settings(self, mock_proxy_config, mock_auth):+ def test_update_sso_settings(self, mock_proxy_config, mock_auth, monkeypatch):+ monkeypatch.setenv("LITELLM_SALT_KEY", "test_salt_key")"""Test updating the SSO settings"""# New SSO settings to updatenew_sso_settings = {@@ -308,11 +309,11 @@ class TestProxySettingEndpoints:updated_config = mock_proxy_config["config"]assert (updated_config["environment_variables"]["GOOGLE_CLIENT_ID"]- == new_sso_settings["google_client_id"]+ != new_sso_settings["google_client_id"])assert (updated_config["environment_variables"]["GOOGLE_CLIENT_SECRET"]- == new_sso_settings["google_client_secret"]+ != new_sso_settings["google_client_secret"])assert (updated_config["general_settings"]["proxy_admin_email"]