feat: add load_path.py for RBAC permission registration

This commit is contained in:
yumoqing 2026-05-27 16:40:58 +08:00
parent 23aaf3dd0b
commit f066bdd960

32
scripts/load_path.py Normal file
View File

@ -0,0 +1,32 @@
"""
appbase 模块 RBAC 权限注册脚本
执行方式: cd ~/repos/sage && ./py3/bin/python ../appbase/scripts/load_path.py
"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from rbac.rbac import set_path_perm
PERMISSIONS = [
# appbase 主页面
{'path': '/appbase', 'permtype': 'logined', 'method': 'any'},
# UI 页面
{'path': '/appbase/menu.ui', 'permtype': 'logined', 'method': 'any'},
{'path': '/appbase/cron/index.ui', 'permtype': 'logined', 'method': 'any'},
# DSPY 接口
{'path': '/appbase/get_code.dspy', 'permtype': 'logined', 'method': 'any'},
{'path': '/appbase/get_appcodes_kv.dspy', 'permtype': 'logined', 'method': 'any'},
{'path': '/appbase/show_icon.dspy', 'permtype': 'logined', 'method': 'any'},
{'path': '/appbase/cron/switch_bizdate.dspy', 'permtype': 'logined', 'method': 'any'},
]
async def main():
for perm in PERMISSIONS:
await set_path_perm(perm['path'], perm['permtype'], method=perm['method'])
print(f"OK: {perm['path']} -> {perm['permtype']}")
if __name__ == '__main__':
import asyncio
asyncio.run(main())