feat: AuditLog 模型与索引注册(里程碑 2)
- AuditLog Extension(group audit.example.com 占位)+ AuditLogSpec,字段与产品设计 4.1 一一对应 - 操作时间复用 metadata.creationTimestamp(D3) - start() 注册 6 个业务索引(username/resourceType/method/statusCode/resourceName/path),stop() 注销 - 资源名称/路径索引用于关键字模糊筛选(QueryFactory.contains 需索引字段) - 生命周期测试覆盖注册索引清单与注销
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package run.halo.operationaudit.audit;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 审计日志业务字段,与产品设计文档 4.1 表格一一对应。
|
||||
*
|
||||
* <p>操作时间使用 {@code metadata.creationTimestamp}(技术方案 D3)。
|
||||
*/
|
||||
@Data
|
||||
public class AuditLogSpec {
|
||||
|
||||
/** 操作者用户名;登录失败记 {@link #UNKNOWN_USERNAME}。 */
|
||||
private String username;
|
||||
|
||||
/** HTTP 方法(动作),如 POST/PUT/DELETE/PATCH。 */
|
||||
private String method;
|
||||
|
||||
/** 资源类型(复数形式,如 posts/comments/users/auth)。 */
|
||||
private String resourceType;
|
||||
|
||||
/** 资源名称;集合级操作或登录端点为空。 */
|
||||
private String resourceName;
|
||||
|
||||
/** 完整请求路径(资源语义解析的兜底,保证完整性)。 */
|
||||
private String path;
|
||||
|
||||
/** 响应状态码(结果:2xx 成功,其余失败)。 */
|
||||
private Integer statusCode;
|
||||
|
||||
/** 来源 IP。 */
|
||||
private String remoteIp;
|
||||
|
||||
/** User-Agent。 */
|
||||
private String userAgent;
|
||||
|
||||
/** 登录失败等无法确定操作者时的占位用户名。 */
|
||||
public static final String UNKNOWN_USERNAME = "unknown";
|
||||
}
|
||||
Reference in New Issue
Block a user