公网临时链接改为不透明短 ID(/p/<22字符>),不再暴露文件名/会话名/签名
- public-files.js(新): 内存表 id → (会话, 相对路径, 过期时间);mint 顺手清过期项并兜底上限 - routes/public-files.js(新): GET /p/<id> 匿名取用(查表 → resolveInTask 复核 → sendDownload),未命中/过期一律 404 - routes/public-link.js: 不再签 HMAC,改为 mint 短 ID,返回 http://<IP>:8090/p/<id>(约 50 字符、纯 ASCII) 动因:原 URL 把文件名写了两遍再挂 64 位签名,共 300+ 字符;它会被模型抄进工具参数、并长期留在会话历史每轮重发 - download-send.js(新): 从 files.js 抽出 sendDownload/downloadDisposition,供浏览器下载与公网取用共用 - server.js: /p 挂在 auth.middleware 之前(匿名可达);浏览器下载那套签名链接保持不动 - docs: DEPLOY.md 4.1 / ARCHITECTURE.md(文件树、路由表、约束)/ README.md 同步
This commit is contained in:
@@ -31,6 +31,11 @@ app.use(express.json({ limit: '2mb' }));
|
||||
// 相比 nginx htpasswd 的 basic auth,cookie 在手机浏览器原生下载时也会自动携带,下载不再失败。
|
||||
const auth = createAuth(cfg);
|
||||
app.use(auth.router); // /login、/logout、/api/login 等免认证端点
|
||||
|
||||
// 公网临时文件的取用端点(GET /p/<id>):匿名可达,必须挂在 auth.middleware 之前。
|
||||
// 安全性来自“22 字符随机 ID + 服务端过期”,详见 routes/public-files.js 头注释。
|
||||
app.use('/p', require('./routes/public-files'));
|
||||
|
||||
app.use(auth.middleware); // 其余请求需登录态(cookie 或 Basic 头)
|
||||
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
Reference in New Issue
Block a user