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
fix(endpoints.py): encrypt credentials before storing in db
Krrish Dholakia507640bc8f2d
diff --git a/litellm/proxy/credential_endpoints/endpoints.py b/litellm/proxy/credential_endpoints/endpoints.pyindex 5a9670406fc..4ed0f07539c 100644--- a/litellm/proxy/credential_endpoints/endpoints.py+++ b/litellm/proxy/credential_endpoints/endpoints.py@@ -12,12 +12,22 @@ import litellmfrom litellm._logging import verbose_proxy_loggerfrom litellm.proxy._types import CommonProxyErrors, UserAPIKeyAuthfrom litellm.proxy.auth.user_api_key_auth import user_api_key_auth+from litellm.proxy.common_utils.encrypt_decrypt_utils import encrypt_value_helperfrom litellm.proxy.utils import handle_exception_on_proxy, jsonify_objectfrom litellm.types.utils import CredentialItemrouter = APIRouter()+def encrypt_credential_values(credential: CredentialItem) -> CredentialItem:+ """Encrypt values in credential.credential_values and add to DB"""+ encrypted_credential_values = {}+ for key, value in credential.credential_values.items():+ encrypted_credential_values[key] = encrypt_value_helper(value)+ credential.credential_values = encrypted_credential_values+ return credential++@router.post("/v1/credentials",dependencies=[Depends(user_api_key_auth)],@@ -42,6 +52,7 @@ async def create_credential(detail={"error": CommonProxyErrors.db_not_connected_error.value},)+ credential = encrypt_credential_values(credential)credentials_dict = credential.model_dump()credentials_dict_jsonified = jsonify_object(credentials_dict)await prisma_client.db.litellm_credentialstable.create(