feat(audit): 添加全局无侵入审计日志拦截器

This commit is contained in:
DXC
2026-04-22 10:41:15 +08:00
parent ab353e5b34
commit 4b794b9bcc
2 changed files with 313 additions and 0 deletions

View File

@ -20,6 +20,17 @@ def create_app():
# 允许所有 /api/ 开头的请求跨域,支持 credentials
cors.init_app(app, resources={r"/*": {"origins": "*"}}, supports_credentials=True)
# =========================================================
# 1.1 注册全局审计日志监听器
# =========================================================
with app.app_context():
try:
from app.utils.audit_events import register_audit_events
register_audit_events(db)
print("✅ 审计事件监听器注册成功")
except Exception as e:
print(f"⚠️ 审计事件监听器注册失败: {e}")
# =========================================================
# 2. 注册蓝图 (Blueprints)
# ---------------------------------------------------------