fix(airag): AI 应用与评估器(外挂数据)接口补权限校验,附按钮权限升级 SQL

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
scott 2026-10-24 05:34:35 -04:00
parent 4436c5af81
commit 0582032e91
3 changed files with 52 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
@ -73,6 +74,7 @@ public class AiragAppController extends JeecgController<AiragApp, IAiragAppServi
* @return 应用字典列表
*/
@GetMapping(value = "/listDict")
@RequiresPermissions(value = {"airag:app:listDict", "airag:flow:debug"}, logical = Logical.OR)
public Result<List<DictModel>> listDict(AiragApp airagApp, HttpServletRequest req) {
QueryWrapper<AiragApp> queryWrapper = QueryGenerator.initQueryWrapper(airagApp, req.getParameterMap());
queryWrapper.select("id", "name");
@ -138,6 +140,7 @@ public class AiragAppController extends JeecgController<AiragApp, IAiragAppServi
* @return
*/
@RequestMapping(value = "/release", method = RequestMethod.POST)
@RequiresPermissions("airag:app:release")
public Result<String> release(@RequestParam(name = "id") String id,
@RequestParam(name = "release") Boolean release,
HttpServletRequest request) {
@ -194,6 +197,7 @@ public class AiragAppController extends JeecgController<AiragApp, IAiragAppServi
* @return
*/
@GetMapping(value = "/queryById")
@RequiresPermissions("airag:app:queryById")
public Result<AiragApp> queryById(@RequestParam(name = "id", required = true) String id) {
AiragApp airagApp = airagAppService.getById(id);
if (airagApp == null) {

View File

@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
@ -50,6 +51,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
//@AutoLog(value = "airag_ext_data-分页列表查询")
@Operation(summary="airag_ext_data-分页列表查询")
@GetMapping(value = "/list")
@RequiresPermissions("airag:extData:list")
public Result<IPage<AiragExtData>> queryPageList(AiragExtData airagExtData,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@ -71,6 +73,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
*/
@Operation(summary="airag_ext_data-分页列表查询")
@GetMapping(value = "/getTrackList")
@RequiresPermissions("airag:extData:getTrackList")
public Result<IPage<AiragExtData>> getTrackList(AiragExtData airagExtData,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@ -95,6 +98,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
@AutoLog(value = "airag_ext_data-添加")
@Operation(summary="airag_ext_data-添加")
@PostMapping(value = "/add")
@RequiresPermissions("airag:extData:add")
public Result<String> add(@RequestBody AiragExtData airagExtData) {
airagExtData.setBizType(AiPromptsConsts.BIZ_TYPE_EVALUATOR);
airagExtDataService.save(airagExtData);
@ -110,6 +114,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
@AutoLog(value = "airag_ext_data-编辑")
@Operation(summary="airag_ext_data-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
@RequiresPermissions("airag:extData:edit")
public Result<String> edit(@RequestBody AiragExtData airagExtData) {
airagExtDataService.updateById(airagExtData);
return Result.OK("编辑成功!");
@ -124,6 +129,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
@AutoLog(value = "airag_ext_data-通过id删除")
@Operation(summary="airag_ext_data-通过id删除")
@DeleteMapping(value = "/delete")
@RequiresPermissions("airag:extData:delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
airagExtDataService.removeById(id);
return Result.OK("删除成功!");
@ -138,6 +144,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
@AutoLog(value = "airag_ext_data-批量删除")
@Operation(summary="airag_ext_data-批量删除")
@DeleteMapping(value = "/deleteBatch")
@RequiresPermissions("airag:extData:deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.airagExtDataService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
@ -152,6 +159,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
//@AutoLog(value = "airag_ext_data-通过id查询")
@Operation(summary="airag_ext_data-通过id查询")
@GetMapping(value = "/queryById")
@RequiresPermissions("airag:extData:queryById")
public Result<AiragExtData> queryById(@RequestParam(name="id",required=true) String id) {
AiragExtData airagExtData = airagExtDataService.getById(id);
if(airagExtData==null) {
@ -168,6 +176,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
//@AutoLog(value = "airag_ext_data-通过id查询")
@Operation(summary="airag_ext_data-通过id查询")
@GetMapping(value = "/queryTrackById")
@RequiresPermissions("airag:extData:queryTrackById")
public Result<List<AiragExtData>> queryTrackById(@RequestParam(name="id",required=true) String id) {
AiragExtData airagExtData = airagExtDataService.getById(id);
String status = airagExtData.getStatus();
@ -184,6 +193,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
* @return
*/
@PostMapping(value = "/evaluator/debug")
@RequiresPermissions("airag:extData:debug")
public Result<?> debugEvaluator(@RequestBody AiragDebugVo debugVo) {
return airagExtDataService.debugEvaluator(debugVo);
}
@ -194,6 +204,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
* @param airagExtData
*/
@RequestMapping(value = "/exportXls")
@RequiresPermissions("airag:extData:exportXls")
public ModelAndView exportXls(HttpServletRequest request, AiragExtData airagExtData) {
return super.exportXls(request, airagExtData, AiragExtData.class, "airag_ext_data");
}
@ -206,6 +217,7 @@ public class AiragExtDataController extends JeecgController<AiragExtData, IAirag
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
@RequiresPermissions("airag:extData:importExcel")
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, AiragExtData.class);
}

View File

@ -0,0 +1,36 @@
-- ---author:wangshuai---date:20261015-----for:AiragExtDataController(AI评估器)全部接口缺失权限注解,任意登录用户可越权读取/篡改/删除评估器和调用轨迹、调用模型;新增 airag:extData:* 按钮权限并授权给系统管理员角色(parent_id=2000880658872508417 为 AI评估器菜单)
-- 1. 新增按钮权限
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000001', '2000880658872508417', '查询AI评估器列表', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:list', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000002', '2000880658872508417', '查询AI评估器调用轨迹列表', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:getTrackList', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000003', '2000880658872508417', '新增AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000004', '2000880658872508417', '编辑AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000005', '2000880658872508417', '删除AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000006', '2000880658872508417', '批量删除AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000007', '2000880658872508417', '按ID查询AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:queryById', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000008', '2000880658872508417', '按ID查询AI评估器调用轨迹', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:queryTrackById', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000009', '2000880658872508417', 'AI评估器调试', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:debug', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000010', '2000880658872508417', '导出AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000011', '2000880658872508417', '导入AI评估器', NULL, NULL, 0, NULL, NULL, 2, 'airag:extData:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
-- 2. 给系统管理员角色(f6817f48af4fb3af11b9e8bf182f618b)授权
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000021', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000001', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000022', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000002', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000023', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000003', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000024', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000004', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000025', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000005', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000026', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000006', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000027', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000007', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000028', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000008', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000029', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000009', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000030', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000010', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000031', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000011', NULL, '2026-10-15 10:00:00', '127.0.0.1');
-- 3. AiragAppController queryById/release/listDict 独立权限(挂 AI应用管理菜单 1893865471550578689 下)
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000012', '1893865471550578689', '按ID查询AI应用', NULL, NULL, 0, NULL, NULL, 2, 'airag:app:queryById', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000013', '1893865471550578689', '发布/取消发布AI应用', NULL, NULL, 0, NULL, NULL, 2, 'airag:app:release', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('2026101500000000014', '1893865471550578689', '查询AI应用字典', NULL, NULL, 0, NULL, NULL, 2, 'airag:app:listDict', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-10-15 10:00:00', NULL, NULL, 0, 0, '1', 0);
-- 4. 授权给系统管理员角色(f6817f48af4fb3af11b9e8bf182f618b)
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000032', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000012', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000033', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000013', NULL, '2026-10-15 10:00:00', '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('2026101500000000034', 'f6817f48af4fb3af11b9e8bf182f618b', '2026101500000000014', NULL, '2026-10-15 10:00:00', '127.0.0.1');