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']: