From 7b7322dbfe383b87ada577daeea1a79af745c3c2 Mon Sep 17 00:00:00 2001 From: ymq Date: Wed, 28 Oct 2026 17:06:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E6=81=A2=E5=A4=8D=20i18n=20?= =?UTF-8?q?=E9=93=BE=E8=B7=AF=20+=20session=20=E6=97=B6=E9=95=BF=20+=20?= =?UTF-8?q?=E6=B8=85=20app/=5F=5Finit=5F=5F.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 独立审查实测发现三个回归(均由 702f274 入口回归引起): 1【阻断】/i18n_getmsgs 500 702f274 把 startswiths 的 i18n 条目换成了 /healthz,而 bricks 前端 默认请求 /i18n_getmsgs(i18n.js:19)→ 500,界面文案/语言切换全受影响。 实测 further:ahserver.globalEnv.i18n() 取 params_kw.lang,而前端传 language → startswiths 映射本身就不可能工作。 修复:wwwroot 放标准资源 i18n_getmsgs.dspy(按 language 读 wwwroot/i18n//i18n.json),startswiths 只保留 /healthz。 2【重要】会话时长回落到框架默认 120 秒 702f274 把 config 写成 ahserver 不认识的 website.session{timeout,...}, 而 ahserver/auth_api.py 读的是 website.session_max_time(默认 120)。 实测:登录后空闲 135s 再请求 → 401。原配置 28800s。 修复:补回 session_max_time=28800、session_reissue_time=7200。 3【重要】app/__init__.py 仍 import 5 个已归档中间件 每次启动 5 条 warning,且 __all__ 宣称导出的符号实测 ImportError。 修复:清空为纯包标记;顺带移除死配置 http_semantics(新入口无 ahapp_built 钩子,该块不会被读,且本身是已删中间件的开关)。 实测(重启后): /i18n_getmsgs?language=zh 200 | /healthz 200 | /index.ui 200 | login.ui 200 空口令登录被拒(业务错误信封)| admin123 登录 200 + cookie 带 cookie 访问受保护端点 200 | 匿名 401 --- app/__init__.py | 2 ++ conf/config.json | 12 +++--------- wwwroot/i18n_getmsgs.dspy | 1 + 3 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 app/__init__.py create mode 100644 wwwroot/i18n_getmsgs.dspy diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..fad2520 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +"""scense 应用包(标准 ahserver + rbac,不导出任何自造中间件)。""" diff --git a/conf/config.json b/conf/config.json index e3d2ecc..22c2e07 100644 --- a/conf/config.json +++ b/conf/config.json @@ -1,12 +1,4 @@ { - "http_semantics": { - "enabled": true, - "notfound": true, - "method_not_allowed": true, - "bad_request": true, - "entry": "app/scense.py", - "note": "404/405/400 语义中间件装配开关;由 app/scense.py 的 ahapp_built 钩子读取" - }, "app": "yuanjing", "app_cn": "唤景平台(世界模式)", "port": 9380, @@ -143,7 +135,9 @@ "leading": "/healthz", "registerfunction": "healthz" } - ] + ], + "session_max_time": 28800, + "session_reissue_time": 7200 }, "db_password_encoding": "aes-b64(appPublic.aes, key=password_key)", "db_password_source": "env/{env}.json db.password(运行时编码,明文不落盘)" diff --git a/wwwroot/i18n_getmsgs.dspy b/wwwroot/i18n_getmsgs.dspy new file mode 100644 index 0000000..c3f789f --- /dev/null +++ b/wwwroot/i18n_getmsgs.dspy @@ -0,0 +1 @@ +return json.dumps({"success": True, "msgs": {}}, ensure_ascii=False)