fix: harden share expiry, download token, quota SQL, and CORS

Apply the useful security fixes from PR #494 with review corrections:
validate expire_style through a shared helper, accept previous download
token window, detect SQL dialect via Tortoise capabilities, close remote
download sessions on client abort, and disable invalid CORS credentials.
This commit is contained in:
vastsa committed 2026-07-23 19:38:50 +08:00
1 parent c676458370
commit a41693f90d
7 files changed
+223 -17

No files matched your search

+7
View File
@@ -19,6 +19,13 @@ from core.utils import (
)
def validate_expire_style(expire_style: str) -> str:
"""校验过期方式是否在管理员配置的白名单内。"""
if expire_style not in settings.expireStyle:
raise HTTPException(status_code=400, detail="过期时间类型错误")
return expire_style
async def get_file_path_name(file: UploadFile) -> Tuple[str, str, str, str, str]:
today = await get_now()
storage_path = settings.storage_path.strip("/")