```
feat: 添加飞书集成和改进安全配置 - 集成 lark-oapi 库以支持飞书功能 - 改进 CORS 配置验证器以支持 JSON 格式输入 - 添加安全凭证检查逻辑以防止跨域安全问题 - 在 DirectLLMAdapter 中增加响应解析异常处理 fix: 增强查询参数验证和分页限制 - 为多个路由添加 Query 参数验证器 - 实现 bounded_limit 和 bounded_offset 辅助函数 - 设置查询限制范围为 1-500 之间 - 使用 secrets.compare_digest 提升令牌验证安全性 refactor: 调整文档忽略规则和测试配置 - 更新 .gitignore 文件中的文档路径配置 - 在 smoke 测试中添加必要的环境变量配置 - 重构配置验证器以提高类型兼容性 ```
This commit is contained in:
@@ -64,10 +64,18 @@ class Settings(BaseSettings):
|
||||
|
||||
@field_validator("cors_origins", mode="before")
|
||||
@classmethod
|
||||
def parse_cors_origins(cls, value: str | list[str]) -> list[str]:
|
||||
def parse_cors_origins(cls, value: Any) -> list[str]:
|
||||
if isinstance(value, list):
|
||||
return value
|
||||
return [item.strip() for item in value.split(",") if item.strip()]
|
||||
return [str(item).strip() for item in value if str(item).strip()]
|
||||
if value is None:
|
||||
return []
|
||||
text = str(value).strip()
|
||||
if text.startswith("["):
|
||||
data = json.loads(text)
|
||||
if not isinstance(data, list):
|
||||
raise ValueError("CORS_ORIGINS must be a CSV string or JSON list")
|
||||
return [str(item).strip() for item in data if str(item).strip()]
|
||||
return [item.strip() for item in text.split(",") if item.strip()]
|
||||
|
||||
@field_validator("openclaw_allowed_tools", "openclaw_allowed_actions", mode="before")
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user