fix(alist): 网关鉴权头改为 X-Gateway-Token
- 依据 2026-09-28 实测:旧头对新网关 4/4 源返回 401,X-Gateway-Token 返回 200 - 取件通道 scripts/artifact_fetch.py 两处头名同步;镜像内生效需重建 worker - 修正过期结论:下载直链 /p/<path>?sign=… 为签名鉴权,请求头不影响(无头亦 206) - 同步文档与回归断言表述(重定向隔离测试仍 PASS)
This commit is contained in:
@@ -190,7 +190,7 @@ def alist_download(manifest, max_bytes):
|
||||
path = "/" + manifest["relative_path"].lstrip("/")
|
||||
payload = json.dumps({"path": path, "password": ""}).encode("utf-8")
|
||||
request = urllib.request.Request(base_url + "/api/fs/get", data=payload, method="POST", headers={
|
||||
"x-api-token": token, "Content-Type": "application/json", "Accept": "application/json",
|
||||
"X-Gateway-Token": token, "Content-Type": "application/json", "Accept": "application/json",
|
||||
"User-Agent": "governance-artifact-fetch/1.0",
|
||||
})
|
||||
try:
|
||||
@@ -209,11 +209,11 @@ def alist_download(manifest, max_bytes):
|
||||
if manifest.get("size_bytes") in (None, 0) and data.get("size"):
|
||||
manifest["size_bytes"] = int(data["size"])
|
||||
download_url = urllib.parse.urljoin(base_url + "/", raw_url.lstrip("/"))
|
||||
# This AList deployment gates the download route with x-api-token (the
|
||||
# Authorization header is NOT recognized there): wrong auth yields a 302
|
||||
# to the DingTalk login page instead of bytes.
|
||||
# 2026-09-28 实测:该网关的下载直链 /p/<path>?sign=... 由签名鉴权,请求头带
|
||||
# 什么都不影响(无头也是 206);真正需要凭证的是 /api/fs/* 路由。这里仍带上
|
||||
# 网关头,Authorization 兜底保留用于旧网关形态。
|
||||
try:
|
||||
return http_get(download_url, {"x-api-token": token}, 180, max_bytes)
|
||||
return http_get(download_url, {"X-Gateway-Token": token}, 180, max_bytes)
|
||||
except FetchError as error:
|
||||
if error.code == "source_auth_required":
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user