mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
refactor: 移除 API Key 最小长度限制并放宽最大长度至 10000 字符
This commit is contained in:
@@ -349,7 +349,7 @@ class CreateAPIKeyRequest(BaseModel):
|
||||
"""创建 API Key 请求"""
|
||||
|
||||
endpoint_id: str = Field(..., description="Endpoint ID")
|
||||
api_key: str = Field(..., min_length=1, max_length=500, description="API Key")
|
||||
api_key: str = Field(..., min_length=1, max_length=10000, description="API Key")
|
||||
priority: int | None = Field(100, ge=0, le=1000, description="优先级")
|
||||
is_active: bool | None = Field(True, description="是否启用")
|
||||
rpm_limit: int | None = Field(None, ge=0, description="RPM 限制(NULL=自适应)")
|
||||
@@ -362,10 +362,6 @@ class CreateAPIKeyRequest(BaseModel):
|
||||
# 移除首尾空白
|
||||
v = v.strip()
|
||||
|
||||
# 检查最小长度
|
||||
if len(v) < 3:
|
||||
raise ValueError("API Key 长度不能少于 3 个字符")
|
||||
|
||||
# 检查危险字符(不应包含 SQL 注入字符)
|
||||
dangerous_chars = ["'", '"', ";", "--", "/*", "*/", "<", ">"]
|
||||
for char in dangerous_chars:
|
||||
|
||||
@@ -322,7 +322,7 @@ class EndpointAPIKeyCreate(BaseModel):
|
||||
)
|
||||
|
||||
api_key: str = Field(
|
||||
default="", max_length=500, description="API Key(标准认证时必填,将自动加密)"
|
||||
default="", max_length=10000, description="API Key(标准认证时必填,将自动加密)"
|
||||
)
|
||||
auth_type: Literal["api_key", "vertex_ai", "oauth"] = Field(
|
||||
default="api_key",
|
||||
@@ -484,8 +484,7 @@ class EndpointAPIKeyUpdate(BaseModel):
|
||||
|
||||
api_key: str | None = Field(
|
||||
default=None,
|
||||
min_length=3,
|
||||
max_length=500,
|
||||
max_length=10000,
|
||||
description="API Key(标准认证时使用,将自动加密)",
|
||||
)
|
||||
auth_type: Literal["api_key", "vertex_ai", "oauth"] | None = Field(
|
||||
@@ -576,8 +575,6 @@ class EndpointAPIKeyUpdate(BaseModel):
|
||||
return v
|
||||
|
||||
v = v.strip()
|
||||
if len(v) < 3:
|
||||
raise ValueError("API Key 长度不能少于 3 个字符")
|
||||
|
||||
dangerous_chars = ["'", '"', ";", "--", "/*", "*/", "<", ">"]
|
||||
for char in dangerous_chars:
|
||||
|
||||
Reference in New Issue
Block a user