Files
YwxAppThink/docs/guide/operation_log.md
T
yangwx 18101cf11a feat: 上线前安全加固与发布工程化;appmall 由插件迁移为独立应用
安全(P0)
- 发布包签名:新增 scripts/package_keygen.php、scripts/package_verify.php、
  ywxapp\service\PackageVerifier;FrameworkService::apply() 解压前强制验签
  (ywxapp.framework_package_verify,默认开启)
- JWT 收紧:config/jwt.php 移除公开默认密钥,JwtService::assertStrongSecret()
  校验非空 / 长度≥32 / 已知弱值;.env.production.example 键名由 JWT_SECRET_KEY 修正为 JWT_SECRET
- /api/v1/Article:免登录白名单收窄为只读接口,写操作字段白名单 + assertOwner() 越权校验
- 开发者令牌:查找接口不再回显明文、统一失败文案 + 限流
- TemplateInstaller:文件名白名单 + realpath 归一化 + 目录内断言,修复 Zip Slip;补 use ZipArchive
- 后台登录:接入验证码、失败锁定与登录限流(config/ratelimit.php)
- 缓存 / Session 驱动可由 .env 覆盖(CACHE_DRIVER / SESSION_TYPE),集群部署改 redis
- paycenter 支付日志开关改为 PAY_LOG,不再跟随 APP_DEBUG

工程化 / 交付
- 新增 CHANGELOG.md 与 .env.production.example;composer.lock 入库锁定依赖版本
- 插件离线安装 CLI 增加 --uid,后台上传安装透传 uid,付费插件授权校验可通过
- 授权拒绝文案区分「未携带 uid」与「未找到有效授权」,便于排障
- .gitignore 放行 .env.production.example / .env.addon.example / .gitattributes / public/.htaccess

结构
- appmall 由 addon/appmall 迁移为独立应用 app/appmall(市场 / 开发者中心 / 审核 / 分润)
2026-10-22 00:53:39 +08:00

34 lines
1.6 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.
# 管理员操作日志(backend_log)
后台的写操作统一留痕,落 `backend_log` 表(`id / aid / action / ip / remark / create_at`)。
## 日志从哪来
| 来源 | 位置 | 说明 |
|------|------|------|
| 通用增删改 | `BackendBase` 的 `create / edit / del / destroy / restore / multi` | 操作**已成功提交**后记录;失败不留痕(避免失败重试刷屏) |
| 登录 / 退出 | `BackendBase::login()` / `logout()` | 登录**成功与失败都记**;失败时 `aid=0`(还不知道是谁) |
| 业务补充 | `AdminLogger::write($action, $remark, $aid)` | 关键业务操作(如删除附件、清理日志)按需补充 |
`action` 约定为 `controller/action`(如 `Admin/create`)或语义动作(`登录成功` / `退出登录`);
`remark` 放可读摘要(如 `ID:12`)。两字段都有长度上限(100 / 255),超长自动截断。
```php
use ywxapp\library\AdminLogger;
AdminLogger::write('order/refund', '订单号:20260101001,金额:39.00');
AdminLogger::login($account, true, '', $aid); // 登录成功
AdminLogger::login($account, false, '密码错误'); // 登录失败
```
日志写入**永不抛异常**(内部吞掉):审计功能不能反过来阻断业务。
## 后台查看
系统管理 → **操作日志**(`app/backend/controller/Adminlog.php`,权限 `adminlog:index|delete|clean`,首次访问自动补录):
- 按账号 / 昵称 / IP / 备注关键字检索,按动作类型下拉筛选,支持日期区间;
- 删除选中;按保留天数清理(填 `0` = 清空,页面有二次确认)。
CLI 清理:`AdminLogger::clean($days)`,同样 `0` = 清空。