From fccfd775a30692269775572c6f9383c23c162e05 Mon Sep 17 00:00:00 2001 From: bizwings Date: Tue, 1 Sep 2026 06:00:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(BIZ-109):=20=E4=B8=B4=E6=97=B6=E6=94=BE?= =?UTF-8?q?=E8=A1=8C=20GET=20=E5=8F=AA=E8=AF=BB=E6=8E=A5=E5=8F=A3=E9=89=B4?= =?UTF-8?q?=E6=9D=83=EF=BC=88=E5=BA=94=E6=80=A5=E4=BF=AE=E5=A4=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因:BIZ-108 commit 31cabbe0 启用 auth_enabled=True,但 index.html 前端 api() 函数 (L944) 未注入 Authorization header, 导致生产环境「记录」tab 完全不可用(10h+) - 修复方案:require_auth 装饰器增加 AUTH_BYPASS_PATHS 白名单, 仅对 GET /api/records + GET /api/history 临时放行鉴权, 写接口(POST /api/generate、DELETE /api/records/、 preview、compare、statistics)保留鉴权 - 验证:5 接口全验证通过(200/401 符合预期), 外网 192.168.1.99:8085 访问正常 - 跟踪:BIZ-110 由 costcodev 适配前端后移除白名单 - 备份:app.py.bak.biz109.20260901050002 - 闭环:2026-09-01 05:18 GMT+8 by 严维序 (opengineer) --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.py b/app.py index 6876c21..37cf697 100644 --- a/app.py +++ b/app.py @@ -305,9 +305,20 @@ def find_draw_by_gen_time(gen_time): # ============================================================ # 认证装饰器(可选) # ============================================================ +# BIZ-109 临时放行白名单:仅 GET 只读接口临时放行鉴权(应急修复) +# 原因:BIZ-108 启用 auth_enabled 后,index.html 前端未适配 token 注入, +# 导致「记录」tab 完全不可用。临时放行只读接口恢复业务, +# BIZ-110 跟踪 index.html 适配后恢复鉴权。 +# 白名单接口:GET /api/records, GET /api/history +# 保留鉴权接口:所有 POST/DELETE/写接口 +AUTH_BYPASS_PATHS = {'/api/records', '/api/history'} + def require_auth(f): @wraps(f) def decorated(*args, **kwargs): + # BIZ-109 应急:GET 只读接口临时放行 + if request.method == 'GET' and request.path in AUTH_BYPASS_PATHS: + return f(*args, **kwargs) if CONFIG['auth_enabled']: token = request.headers.get('Authorization', '').replace('Bearer ', '') if token != CONFIG['api_token']: