mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
security: exclude mcp_authorization from serialization and logs
Added Field(exclude=True) to mcp_authorization field to ensure tokens are NEVER exposed in: - API responses (model_dump()) - JSON serialization (model_dump_json()) - Logs - Any Pydantic serialization This prevents accidental token leakage through: - Error messages - Debug logs - API response payloads - Monitoring/telemetry systems The field is still accessible within the application code but will be automatically excluded from all Pydantic serialization operations.
This commit is contained in:
parent
c353873774
commit
6716e128be
1 changed files with 6 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class MCPProviderDataValidator(BaseModel):
|
||||
|
|
@ -36,7 +36,11 @@ class MCPProviderDataValidator(BaseModel):
|
|||
|
||||
# mcp_endpoint => authorization token
|
||||
# Example: {"http://server.com": "token123"}
|
||||
mcp_authorization: dict[str, str] | None = None
|
||||
# Security: exclude=True ensures this field is NEVER included in:
|
||||
# - API responses
|
||||
# - Logs
|
||||
# - Serialization (model_dump, dict(), json())
|
||||
mcp_authorization: dict[str, str] | None = Field(default=None, exclude=True)
|
||||
|
||||
|
||||
class MCPProviderConfig(BaseModel):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue