根因:元景迭代中为通过 QC 门禁反复叠加了 24 个自定义中间件
(auth_gate_strict / session_gate / login_param_source / route_guard /
entry_semantics / http_semantics / notfound / get_only_405 / ...),
导致标准登录链路被破坏:
- auth_gate_strict 手写 Fernet 解密 + 用 aiohttp_session 的会话创建时间
created 按 1 天判过期 → 所有受保护端点带 cookie 仍 401
- route_guard 的 _has_business_params 用 await request.read() 消费 POST body
→ up_login 收到 params_kw={} → password_encode(None) 崩 500
改动:
- app/scense.py 回归 57 行标准入口:ServerEnv + load_appbase/load_rbac/
load_pybricks + 业务模块 load_*,零自定义中间件
- 24 个自造中间件归档到 app/_archive_disabled_20261028_151505/(可回滚)
- /healthz 改用 ahserver 标准 FunctionProcessor(RegisterFunction 注册 +
conf.website.startswiths 映射),不再用中间件拦截
实测闭环(127.0.0.1:9380 + https://gbak.opencomputing.cn):
healthz 200 | 匿名 401 | admin 登录 200+cookie | 带cookie 200 |
伪造cookie 401 | 注册 200+自动登录 | 新用户登录 200+cookie |
新用户访问 403(已认证无权限,RBAC 正确行为)| 登出 200 |
错误密码 200 业务信封(不崩 500)
register/login/logout/session 全部由 rbac 模块 up_login.dspy /
register.dspy / logout.dspy + ahserver session 中间件提供。
scense 游戏展示模块(元景 W-08)
功能
游戏列表入口 / 点击开始玩(初始化 W-10 世界运行态进入)/ 暂停 / 继续 / 结束结算 / 重新开始 / 分数结果展示 / 分享链接进入 / 玩中交互(点选移动实体触发脚本逻辑)/ 退出保存进度。
数据表
| 表 | 作用 | 关键字段 |
|---|---|---|
| game_session | 游戏会话 | status(created/playing/paused/ended), score, level, elapsed_ms, progress_json, share_token |
| game_result | 游戏结果 | session_id, score, duration_ms, level, result_json |
会话状态机
- 开始玩:无会话→playing;已有 playing/paused→恢复 playing(续玩)
- playing ⇄ paused(pause/resume)
- playing/paused → ended(end 唯一结算出口,写 game_result)
- 任意状态 → playing(restart 重置分数/关卡)
- save 保存进度快照(不改变状态)
API 端点(wwwroot/game/api/*.dspy,全部 logined)
| 文件 | 功能 | 功能点 |
|---|---|---|
| game_list.dspy | 游戏列表 + 历史会话/结果 | W-08a |
| game_start.dspy | 开始玩(进入运行态) | W-08b |
| game_pause.dspy | 暂停 | W-08c |
| game_resume.dspy | 继续 | W-08d |
| game_end.dspy | 结束结算(写 game_result) | W-08e/g |
| game_restart.dspy | 重新开始(重置) | W-08f |
| game_share.dspy | 生成/解析分享链接 | W-08h |
| game_save.dspy | 保存进度快照 | W-08j |
前端
game/index.ui— bricks 游戏列表入口页game/game_play.html— 全屏游戏页(canvas + HUD + 结算面板 + 交互),验收入口game/game.js— 游戏交互(开始/暂停/继续/结束/重开/分享/保存/点选实体)game/game_list.js— 列表页渲染
依赖
- W-10 runtime(runtime.js RuntimeEngine,前端运行态,服务端辅助可选)
- world 模块(游戏世界来源,防御式降级独立模式)
- sqlor / ahserver / ServerEnv
集成
app/sage.py:from scense.init import load_scense+load_scense()in init()- build.sh 安装循环添加 scense
scripts/load_path.py注册 RBAC 路径(禁通配符)global_menu.ui添加菜单项{{entire_url('/scense/game/index.ui')}}- 部署目标
/d/scense/scense_app:模块 wwwroot 软链接 + pip install -e
Description