- build.sh四处清单(mv/pip install/xls2ui/软链)删pipeline_dist - app/pipeline_app.py删import+load_pipeline_dist() - conf/config.json删module_dbname条目; conf/rp.json删/pipeline_dist两条 - bin/init_perms.py删分销管理访问权限; scripts/load_path.py删3条RBAC路径 - scripts/merge_i18n.py删MODULES条目; wwwroot/index.ui删分销管理菜单项 - deploy/smoke/cases.json删s09营销产线壳用例 - i18n源+产物删5词条(分销商产线配置/分销商管理/分销管理/2条描述语) - wwwroot/pipeline_dist软链删除(git跟踪) - deploy/migrations/m0020登记DROP两表+清码表+清权限(破坏性,dmig拒绝自动执行,人工复核手工跑;测试机两表0行) - supplychain的sub_distributor*权限/表不受影响(path前缀与表名均不同)
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Initialize RBAC permissions for pipeline modules."""
|
|
import sys, os, asyncio
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT_DIR = os.path.dirname(SCRIPT_DIR)
|
|
sys.path.insert(0, os.path.join(ROOT_DIR, 'py3', 'lib', 'python3.10', 'site-packages'))
|
|
sys.path.insert(0, ROOT_DIR)
|
|
|
|
from sqlor.dbpools import DBPools
|
|
from appPublic.jsonConfig import getConfig
|
|
from appPublic.folderUtils import ProgramPath
|
|
from appPublic.uniqueID import getID
|
|
from ahserver.serverenv import ServerEnv
|
|
from ahserver.globalEnv import initEnv
|
|
|
|
PERMS = [
|
|
('/pipeline_core/', '产线管理访问', 'pipeline_core', 'logined'),
|
|
('/pipeline-sdlc/', '开发产线访问', 'pipeline_sdlc', 'logined'),
|
|
('/pipeline_ops/', '运营管理访问', 'pipeline_ops', 'logined'),
|
|
('/pipeline_task/', '任务中心访问', 'pipeline_task', 'logined'),
|
|
('/showcase/', '展示平台访问', 'showcase', 'guest'),
|
|
('/', '应用首页', 'app', 'guest'),
|
|
]
|
|
|
|
async def init_perms():
|
|
config = getConfig(ROOT_DIR, NS={'workdir': ROOT_DIR, 'ProgramPath': ProgramPath()})
|
|
DBPools(config.databases)
|
|
initEnv()
|
|
env = ServerEnv()
|
|
env.get_module_dbname = lambda m: 'sage'
|
|
|
|
async with DBPools().sqlorContext('sage') as sor:
|
|
for path, name, perm_type, role_name in PERMS:
|
|
# Build safe SQL with repr
|
|
sql = "SELECT id FROM permission WHERE path=" + repr(path) + " LIMIT 1"
|
|
existing = await sor.sqlExe(sql, {})
|
|
if existing:
|
|
print('SKIP {:<8s} {}'.format(role_name, path))
|
|
continue
|
|
|
|
pid = getID()
|
|
await sor.C('permission', {
|
|
'id': pid, 'name': name, 'path': path,
|
|
'permtype': perm_type
|
|
})
|
|
role_sql = "SELECT id FROM role WHERE name=" + repr(role_name) + " LIMIT 1"
|
|
role_recs = await sor.sqlExe(role_sql, {})
|
|
if role_recs:
|
|
await sor.C('rolepermission', {
|
|
'id': getID(),
|
|
'roleid': role_recs[0].id,
|
|
'permid': pid
|
|
})
|
|
print('ADD {:<8s} {}'.format(role_name, path))
|
|
|
|
print('\nInitialized {} permissions'.format(len(PERMS)))
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(init_perms())
|