签入版本

This commit is contained in:
2026-10-09 10:50:38 +08:00
parent 40a263ce22
commit fbdc4b54f1
18 changed files with 57 additions and 75 deletions
@@ -52,7 +52,7 @@
▼
┌──────────────┐
│ LogOperation │ 记录操作日志(terminable,响应后写入)
│(log.operation)│ 写操作始终记录
│(log.operation)│ 写操作始终记录(#[WithoutOperationLog] 跳过)
└──────┬───────┘
│
▼
@@ -73,31 +73,19 @@
| ProxyMiddleware | API 组前置 | 代理头解析,提取真实客户端 IP | `.env` → `TRUSTED_PROXIES` |
| Cors | API 组前置 | 跨域处理(OPTIONS 预检 + 响应头) | `config/cors.php` → `CORS_ALLOW_ORIGIN` |
| ForceJsonResponse | API 组前置 | 强制 `Content-Type: application/json` | — |
| Authenticate | 路由组(别名 `auth.jwt`) | JWT 认证 + 权限校验(`#[Permission]` 注解) | `config/middleware.php` → `auth_except` |
| Authenticate | 路由组(别名 `auth.jwt`) | JWT 认证 + 权限校验(`#[Permission]` 注解) | `config/jwt.php` → `header_prefix` |
| ResolveTenant | 路由组(别名 `tenant`) | 租户上下文注入与校验 | 超管(uid=1)跳过校验 |
| LogOperation | 路由组(别名 `log.operation`) | 操作日志记录(terminable,响应后落库) | `config/middleware.php` → `log_except` |
| LogOperation | 路由组(别名 `log.operation`) | 操作日志记录(terminable,响应后落库,`#[WithoutOperationLog]` 跳过) | — |
| DemoMiddleware | 路由组(别名 `demo`,tenant 与 log.operation 之间) | 演示模式拦截写操作(无 `#[DemoAllow]` 的写操作返回 403) | `config('app.demo_mode')` |
## 排除配置
## 排除方式
```php
// config/middleware.php
return [
// Authenticate::handle() 命中时跳过 JWT 解析与权限校验(公开接口定义在路由组外,此为兜底)
'auth_except' => [
'login',
'captcha',
'refresh',
],
// LogOperation::handle() 命中时不写入 OperationLog
// 登录/登出由 LoginLog 单独记录
'log_except' => [
'login',
'logout',
'captcha',
],
];
```
| 目标 | 机制 | 说明 |
|------|------|------|
| 认证(`auth.jwt`) | 路由分组 | 公开接口(`login`、`captcha`、`refresh`、`oauth2`)定义在认证组外,天然免认证 |
| 操作日志(`log.operation`) | `#[WithoutOperationLog]` 注解 | 方法标注即不写入 `OperationLog`,优先级高于"写操作一律记录";适用于已有专门日志载体的接口,如登出记录写入登录日志(`login_log`,`log_type=2`) |
操作日志排除机制详见 [4.2 请求处理链路](/zh/architecture/request-flow.html)。
## 注入内容