Files
qipai/docs/devlogs/2026-06-18-M02-B-微信登录与会话.md
T
2026-06-18 10:46:39 +08:00

39 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# M02-B 微信登录与用户体系
- 日期:2026-06-18
- 起始 commit`0db9505`
- 工程 commit`647ef7c`
- 推送校验:`HEAD == origin/main == 647ef7c83c402b114d89f1a03314c69a399a4282`
- ENGINEERING_DELTA=YES
- 子阶段状态:DONE
## 工程增量
- 新增租户用户、应用身份和可撤销会话迁移。
- 新增微信 `jscode2session` 客户端,AppSecret 仅从运行环境 JSON 映射读取。
- 新增 HS256 JWT 签发/验签,令牌含 tenant、user、session、platform app 与 role version。
- 新增微信登录、当前用户和注销接口。
- 所有鉴权均回查 MySQL 会话、用户状态和角色版本。
## 已执行验证
1. `npm test``backend/`
- 退出码 0。
- JWT 签名/篡改/过期、登录、当前用户、注销后拒绝、微信错误映射全部 PASS。
2. WSL 原生临时副本运行 `bash scripts/dev/wsl/mysql-migration-roundtrip.sh`
- MySQL `8.4.9-0ubuntu0.26.04.1`
- `up → verify → down → up → verify`22 条 up、12 条 verify、21 条 down。
- OpenID 用户复用、会话撤销、角色版本即时失效全部 PASS。
3. `git diff --check`
- 退出码 0。
## 边界与影响
- 数据库:新增迁移 `2026061804`
- API:新增 `/app-api/auth/wechat-login``/app-api/auth/me``/app-api/auth/logout`
- 配置:新增 JWT TTL、会话 TTL、JWT Secret 与 AppID/AppSecret JSON 映射。
- 外部依赖:真实微信 code 联调尚需有效 AppSecret;工程适配器、错误处理和自动化测试已完成。
- 部署影响:生产必须在 `/etc/qipai/qipai.secrets` 配置随机 JWT Secret 和微信 AppSecret 映射。
- 小程序:未纳管工作区未跟踪模板,ISSUE-007 继续隔离。
- 下一阶段:M02-C RBAC、门店数据范围和资源归属。