feat: 增强 Gemini 认证支持与 URL 敏感信息脱敏

- 新增 extract_client_api_key_with_query 支持从 URL query 参数提取 API Key
- Gemini 格式遵循 Google SDK 行为:query 参数优先于 header
- 添加 redact_url_for_log 函数对日志中的敏感 URL 参数脱敏
- 上游请求始终使用 header 认证,清除 Gemini query 中的 key 参数
- 放宽 API Key 最小长度限制至 3 字符
- 完善认证方式相关代码注释
This commit is contained in:
fawney19
2026-01-22 19:11:38 +08:00
parent 1d27284575
commit ee5ba42b79
12 changed files with 176 additions and 40 deletions

View File

@@ -76,7 +76,8 @@ def _detect_api_format_and_key(request: Request) -> Tuple[str, Optional[str]]:
Returns:
(api_format, api_key) 元组
"""
return detect_format_and_key_from_starlette(request)
format_name, api_key, _auth_method = detect_format_and_key_from_starlette(request)
return format_name, api_key
def _get_formats_for_api(api_format: str) -> list[str]: