314 Commits

Author SHA1 Message Date
MarSeventh
143bda1ce2 feat: 会话安全策略 - 后端支持动态 Secure/MaxAge 配置
- 扩展 getSecurityConfig 和 fetchSecurityConfig 默认值,新增 sessionSecure、userSessionMaxAge、adminSessionMaxAge 字段
- 改造 buildSessionCookie 支持 secure 参数
- createSession 根据 authType 动态读取配置计算 maxAge
- destroySession 读取 sessionSecure 确保清除 Cookie 属性一致
2026-04-21 10:58:54 +08:00
MarSeventh
c25bbfe4a7 fix: remove Secure flag from session cookie for HTTP Docker compatibility 2026-04-19 20:16:36 +08:00
MarSeventh
1faf4d8a6f fix: use createResponse in huggingface upload endpoints to include CORS headers
Replace all new Response calls in commitUpload.js and getUploadUrl.js with
createResponse from uploadTools so that responses include Access-Control-Allow-Origin
and other CORS headers, fixing cross-origin requests.
2026-04-19 16:47:37 +08:00
MarSeventh
9bb7172651 fix: D1模式下分块上传失败时不保存二进制数据,避免SQLITE_TOOBIG 2026-04-19 11:17:34 +08:00
MarSeventh
40f091db05 fix: sessionCheck adminRequired should also consider password-only config 2026-04-18 16:23:20 +08:00
MarSeventh
888dba1a80 refactor: extract rehashIfNeeded to passwordHash.js, deduplicate login rehash logic 2026-04-18 15:35:13 +08:00
MarSeventh
23a7f69dc4 fix: return explicit authType instead of null when auth is unconfigured
- checkAdmin: return 'admin' when admin auth not configured
- checkUser: return 'user' when authCode not configured
- directoryTree: use authType !== 'admin' to gate user-only checks
2026-04-18 15:28:01 +08:00
MarSeventh
6cf23fec70 refactor: split authCore into checkAdmin/checkUser, extract API Token to public layer 2026-04-18 15:05:49 +08:00
MarSeventh
7ad7bf364b refactor: remove Basic Auth, add /api/auth/adminLogin endpoint
- Remove Basic Auth (verifyBasicAuth, parseBasicAuth) from authCore.js
- Add /api/auth/adminLogin POST endpoint for admin login via JSON body
- Delete legacy /api/manage/check, login, logout (no longer referenced)
- Fix adminConfigured to consider password-only config
2026-04-18 14:49:01 +08:00
MarSeventh
1e96f2e27b refactor: unify auth logic into authCore with authScope parameter
- Extract shared authentication logic into utils/auth/authCore.js
- Replace enableBasicAuth/enableAuthCode flags with clear authScope enum (ADMIN/USER/EITHER)
- Move all auth-related files into utils/auth/ subdirectory
- Eliminate duplicated admin auth logic between _middleware.js and dualAuth.js
- Fix: user session no longer grants access to admin-only endpoints
- Fix: dualAuth no longer bypasses authCode when admin is not configured
- Update all 17 import references across the codebase
- Preserve original function signatures (userAuthCheck, dualAuthCheck) for zero caller changes
2026-04-18 13:24:53 +08:00
MarSeventh
baca53a631 security: upgrade password hashing to PBKDF2 and fix API token generation
- Replace single-round SHA-256 with PBKDF2 (100k iterations) via Web Crypto API
- Auto-rehash old SHA-256/plaintext passwords to PBKDF2 on successful login
- Add timing-safe comparison to prevent timing attacks
- Replace Math.random() with crypto.getRandomValues() for API token and token ID generation
- Maintain full backward compatibility with existing SHA-256 hashes and plaintext passwords
2026-04-18 00:45:04 +08:00
MarSeventh
cb8f0fd1f7 refactor: move auth endpoints to /api/auth/ subdirectory
- login.js -> auth/login.js (/api/auth/login)
- logout.js -> auth/logout.js (/api/auth/logout)
- sessionCheck.js -> auth/sessionCheck.js (/api/auth/sessionCheck)
- resetAuth.js -> auth/resetAuth.js (/api/auth/resetAuth)
- Update import paths in moved files
2026-04-17 23:46:24 +08:00
MarSeventh
43e662ecd7 feat: add /api/resetAuth endpoint for password recovery
Allows resetting all auth config when locked out:
- Requires RESET_KEY environment variable to be set
- GET /api/resetAuth?key=YOUR_RESET_KEY
- Clears security config from database (falls back to env vars)
- Destroys all active sessions
2026-04-17 23:37:11 +08:00
MarSeventh
05b7d21ff1 fix: use ?? for config fallback, add clear password support and auth-required check
- Fix getSecurityConfig: use ?? instead of || so empty string is preserved
- Handle _clear flag to explicitly remove passwords
- Clear adminUsername together with adminPassword on _clear
- sessionCheck now returns adminRequired/userRequired fields
- Return 200 instead of 401 from sessionCheck for frontend to decide
2026-04-17 23:32:27 +08:00
MarSeventh
5e48fde2ca feat: session-based auth with password hashing
- Add passwordHash.js: SHA-256 + salt hashing with plaintext backward compatibility
- Add sessionManager.js: HttpOnly cookie sessions with separate admin_session/user_session
- Add sessionCheck.js: session validation endpoint for frontend route guards
- Add logout.js: session destruction endpoint with authType support
- Update login.js: return user_session cookie on successful login
- Update check.js: return admin_session cookie on successful admin auth
- Update _middleware.js: check admin_session before Basic Auth, remove WWW-Authenticate header
- Update security.js: hash passwords on save, mask in GET, clear sessions on password change
- Update dualAuth.js/userAuth.js: use verifyPassword and session validation
2026-04-17 23:11:45 +08:00
MarSeventh
7c0875bd67 feat: add i18n English labels for page config API 2026-03-28 22:06:46 +08:00
MarSeventh
3d44022947 Feat:细化Token权限,支持设置管理权限 2026-03-10 18:59:03 +08:00
MarSeventh
9441468a5b feat: 添加 API Token 过期时间后端支持
- 新增 tokenExpiration.js 工具模块(过期判定、自动删除过滤)
- apiTokens.js 支持 expiresAt/autoDelete 字段的创建、更新、自动清理
- 新增 getTokenData 导出函数
- tokenValidator.js 增加过期检查逻辑
2026-03-10 10:52:01 +08:00
MarSeventh
3c31520faa Bug:修复HF渠道上传较大文本文件栈溢出的错误 2026-03-08 21:58:32 +08:00
MarSeventh
fc9eab6194 提升索引重建在不同网络环境下的鲁棒性 2026-03-05 12:26:56 +08:00
copilot-swe-agent[bot]
7e41737fc9 Fix missing returnBlockImg import in file handler
Co-authored-by: MarSeventh <108160987+MarSeventh@users.noreply.github.com>
2026-03-03 18:07:43 +00:00
copilot-swe-agent[bot]
81661a3fdb Replace URL rewrite with fetch interceptor to fix url.origin-based logic; fix folder delete/move body consumption bug
Co-authored-by: MarSeventh <108160987+MarSeventh@users.noreply.github.com>
2026-03-03 18:05:41 +00:00
copilot-swe-agent[bot]
3d33b0f662 Fix Docker deployment issues: add request.cf mock, boolean binding in SQLite, caches API mock, graceful purgeCFCache error handling
Co-authored-by: MarSeventh <108160987+MarSeventh@users.noreply.github.com>
2026-03-03 16:46:40 +00:00
MarSeventh
4f33e5d473 Bug:修复偶发的HF渠道移动文件导致文件丢失的问题 2026-03-02 22:13:18 +08:00
MarSeventh
b9af4d5591 Bug:偶发的TG渠道分块上传失败问题修复 2026-03-02 00:19:37 +08:00
MarSeventh
26226c2e10 目录树设置和体验优化 2026-03-01 11:25:39 +08:00
MarSeventh
cfb6e638e2 目录树设置和体验优化 2026-03-01 11:13:43 +08:00
MarSeventh
4955ed1b8d v2.6.1:增加文件夹候选项;部分安全和体验优化 2026-02-28 16:58:42 +08:00
MarSeventh
50ff6d98b1 v2.6.1:增加文件夹候选项;部分安全和体验优化 2026-02-28 16:50:46 +08:00
copilot-swe-agent[bot]
29f64055e1 Add CORS response headers to random API endpoint
Co-authored-by: MarSeventh <108160987+MarSeventh@users.noreply.github.com>
2026-02-27 17:07:24 +00:00
MarSeventh
397b469d9e Bug:依赖漏洞修复 2026-02-26 21:35:53 +08:00
MarSeventh
c02a5bf151 Feat:D1存储支持大文件分块上传 2026-02-24 21:22:56 +08:00
XMZO
206be9313d Update chunkUpload.js 2026-02-24 19:39:57 +08:00
MarSeventh
1be23d730a 路径安全处理逻辑优化 2026-02-24 10:52:32 +08:00
MarSeventh
936220a06d 上传路径识别优化 2026-02-23 16:45:27 +08:00
MarSeventh
2a27ca51ef 后端文件后缀处理逻辑优化 2026-02-23 15:27:47 +08:00
MarSeventh
d1f5c9bd3d 路径穿越检测增强 2026-02-23 15:05:32 +08:00
MarSeventh
8eebf7ed49 重建索引功能优化,提升安全性 2026-02-23 14:43:34 +08:00
MarSeventh
a67d29e471 优化公告设置体验 2026-02-23 14:04:26 +08:00
MarSeventh
91983dcb53 hf渠道大文件上传优化 2026-02-23 13:44:49 +08:00
MarSeventh
978ed2bcf6 v2.5.12:增加路径穿越防护 2026-02-23 13:20:42 +08:00
MarSeventh
49d484debc v2.5.11:随机图API支持设备自适应;管理端支持列表/卡片偏好记录,列表视图支持框选多选 2026-02-09 21:21:08 +08:00
MarSeventh
12069fc3cd v2.5.10:支持文件重命名和文件元数据编辑 2026-02-07 16:00:28 +08:00
MarSeventh
013eb7cfee 尺寸提取功能优化 2026-01-30 17:15:22 +08:00
MarSeventh
a03766a9f9 update v2.5.7 2026-01-30 16:14:19 +08:00
MarSeventh
88c617395f update v2.5.6 2026-01-29 19:59:29 +08:00
Zhang Chao
cdfd983f42 fix(s3/storage): 恢复因合并异常丢失的S3 CDN代码,导致功能失效的问题 2026-01-27 04:20:24 +00:00
MarSeventh
5d34052a1f update v2.5.5 2026-01-25 15:29:35 +08:00
MarSeventh
1625d32ff3 update v2.5.4 2026-01-23 22:40:21 +08:00
MarSeventh
9d4d9fb7bf update v2.5.4 2026-01-23 21:58:25 +08:00