1. json/downapp.json: 添加更新和删除工具栏按钮,移除noedit限制 2. wwwroot/update_apikey.dspy: 查询并返回预填充的更新表单 3. wwwroot/do_update_apikey.dspy: 处理更新表单提交 4. wwwroot/delete_apikey.dspy: 删除API Key及关联应用 5. wwwroot/apikey_manage.ui: 独立API Key管理页面 6. scripts/load_path.py: 使用通配符%/dapi/%注册所有路径
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
"""Generate RBAC permissions for dapi module paths.
|
|
|
|
Run from Sage root with Sage venv:
|
|
cd ~/repos/sage && ./py3/bin/python ../dapi/scripts/load_path.py
|
|
"""
|
|
import os
|
|
import sys
|
|
import asyncio
|
|
|
|
sage_root = os.environ.get('SAGE_ROOT')
|
|
if sage_root and sage_root not in sys.path:
|
|
sys.path.insert(0, sage_root)
|
|
|
|
from sqlor.dbpools import DBPools
|
|
from appPublic.jsonConfig import getConfig
|
|
from appPublic.dictObject import DictObject
|
|
from appPublic.uniqueID import getID
|
|
|
|
|
|
paths = [
|
|
("/dapi", "logined"),
|
|
("/dapi/%", "logined"),
|
|
]
|
|
|
|
|
|
async def main():
|
|
config = getConfig('.')
|
|
DBPools(config.databases)
|
|
dbname = 'sage'
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
cnt = 0
|
|
for path, role in paths:
|
|
r = await sor.sqlExe(
|
|
'select * from permission where permcode = ${permcode}$',
|
|
{'permcode': path}
|
|
)
|
|
if len(r) == 0:
|
|
await sor.sqlExe(
|
|
'''insert into permission (id, permcode, permname, permtype)
|
|
values (${id}$, ${permcode}$, ${permname}$, ${permtype}$)''',
|
|
{
|
|
'id': getID(),
|
|
'permcode': path,
|
|
'permname': path,
|
|
'permtype': role,
|
|
}
|
|
)
|
|
cnt += 1
|
|
print(f'{cnt} path(s) inserted for dapi')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|