跳到内容

操作审计

受众:开发者 / 运维 摘要:Core Audit 操作审计日志底座,负责写操作采集、查询、导出和敏感参数脱敏。

Core Audit 是通用底座能力模块。它记录后台写操作的审计事实,供 Admin 运维、排障和合规留痕使用,不承载业务审批、风控处置或登录审计。

能力范围

能力说明
注解采集@OperationAudit 标记需要审计的操作
请求拦截OperationLogInterceptor 只挂载统一后台入口 /api/v1/admin/**
记录服务OperationLogService 负责参数脱敏、字段截断和失败隔离
查询导出后台分页、详情和 CSV 异步导出

审计失败不回滚已成功的业务写操作。敏感字段需要在进入日志前脱敏,禁止把密码、token、密钥或完整请求体写入审计日志。

API 路径

API说明
GET /api/v1/admin/audit/operation-logs分页查询操作日志
GET /api/v1/admin/audit/operation-logs/{id}查询操作日志详情
POST /api/v1/admin/audit/operation-logs/export创建操作日志 CSV 导出任务

权限前缀为 audit:operation-log:*。Admin 菜单由 Audit seed 维护。

数据模型

说明
audit_operation_log操作人、模块、动作、请求摘要、结果、traceId 和脱敏后的参数快照

迁移归属:

文件说明
spring-open-core/spring-open-core-audit/src/main/resources/db/changelog/migrations/0000_00_00_028000_core_audit_create_tables.xml建表
spring-open-core/spring-open-core-audit/src/main/resources/db/changelog/migrations/0000_00_00_028100_core_audit_seed_data.xml权限、菜单和角色绑定

与其他模块的边界

  • IAM 提供用户、租户、数据范围和后台权限承载。
  • Async Task 提供 CSV 导出执行与产物追踪。
  • Audit 不反向依赖业务模块;业务模块只通过注解或审计命令写入操作事实。
  • 登录审计、支付流水、风控事件和业务状态机日志继续归各 owning module。

验证命令

bash
./mvnw -pl spring-open-core/spring-open-core-audit -am test -DskipITs -DskipFrontend -Dsurefire.failIfNoSpecifiedTests=false
./.ai/scripts/check modules
./.ai/scripts/check migrations
git diff --check

Released under the Apache License 2.0.