60 lines
1.7 KiB
Python
Raw 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 pipeline-opportunity module.
与平台惯例一致:页面/CRUD/API → logined。
在宿主应用根目录执行set_role_perm.py 位于宿主根):
cd <APP_ROOT> && py3/bin/python pkgs/pipeline-opportunity/scripts/load_path.py
"""
import os
import subprocess
import sys
MOD = "pipeline-opportunity"
# set_role_perm.py 在宿主应用根目录(本脚本位于 <APP_ROOT>/pkgs/pipeline-opportunity/scripts/
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
TABLES = [
"opp_reports", "opp_approvals",
]
PATHS_ANY = []
PATHS_LOGINED = [
"/%s" % MOD,
"/%s/index.ui" % MOD,
"/%s/agent" % MOD,
"/%s/agent/index.ui" % MOD,
]
for t in TABLES:
PATHS_LOGINED += [
"/%s/%s/index.ui" % (MOD, t),
"/%s/%s/get_%s.dspy" % (MOD, t, t),
"/%s/%s/add_%s.dspy" % (MOD, t, t),
"/%s/%s/update_%s.dspy" % (MOD, t, t),
"/%s/%s/delete_%s.dspy" % (MOD, t, t),
]
def _run(role, path):
r = subprocess.run([sys.executable, os.path.join(APP_ROOT, "set_role_perm.py"), role, path],
capture_output=True, text=True, cwd=APP_ROOT)
if r.returncode != 0:
print(" FAIL [%s] %s: %s" % (role, path, (r.stderr or "").strip()[:120]))
return r.returncode == 0
def main():
print("=== %s RBAC registration ===" % MOD)
n = 0
for p in PATHS_ANY:
n += _run("any", p)
print(" any: %s" % p)
for p in PATHS_LOGINED:
n += _run("logined", p)
print(" logined: %s" % p)
print("Done. %d/%d paths registered" % (n, len(PATHS_ANY) + len(PATHS_LOGINED)))
if __name__ == "__main__":
main()