app_audit/scripts/load_path.py
yumoqing 55e4ce30b8 feat: 审计日志界面 + DataGrid 分页查询
- index.ui: DataGrid 审计日志列表界面
- audit_service: list_audit_logs 改分页返回 {rows,total}
- audit.dspy: list 返回 DataGrid 格式
- load_path: 注册 /app_audit 界面权限
2026-08-14 13:23:40 +08:00

52 lines
1.4 KiB
Python
Raw Permalink 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.

#!/usr/bin/env python3
"""RBAC path registration for app_audit module.
审计 API 仅 owner.audit 角色审计独立性superuser 也不给)。
"""
import os, sys, subprocess
MOD = "app_audit"
# 审计日志界面 + API仅 owner.audit 角色
PATHS_AUDIT = [
f"/{MOD}",
f"/{MOD}/index.ui",
f"/{MOD}/api/audit.dspy",
]
def find_app_root():
# 从 scripts/ 向上逐层查找 set_role_perm.py位于宿主 app 根目录)
d = os.path.dirname(os.path.abspath(__file__))
for _ in range(6):
if os.path.isfile(os.path.join(d, "set_role_perm.py")):
return d
parent = os.path.dirname(d)
if parent == d:
break
d = parent
return None
def main():
root = find_app_root()
if not root:
print("ERROR: app root not found")
sys.exit(1)
set_perm = os.path.join(root, "set_role_perm.py")
py = sys.executable
count = 0
for role, paths in [("owner.audit", PATHS_AUDIT)]:
for path in paths:
cmd = [py, set_perm, role, path]
r = subprocess.run(cmd, capture_output=True, text=True, cwd=root)
if r.returncode == 0:
count += 1
else:
print(f" WARN: {path} -> {r.stderr.strip()[-80:]}")
print(f"Registered {count}/{len(PATHS_AUDIT)} paths for {MOD}")
if __name__ == "__main__":
main()