问题描述
在SysRoleController.java中的getRoleForm函数及其callee"roleService.getRoleForm"函数未对当前用户的身份进行权限检查,可能导致当前非根用户通过直接输入根用户的Roleid的方式访问根用户角色信息:
@Operation(summary = "角色表单数据")
@GetMapping("/{roleId}/form")
public Result<RoleForm> getRoleForm(
@Parameter(description ="角色ID") @PathVariable Long roleId
) {
RoleForm roleForm = roleService.getRoleForm(roleId);
return Result.success(roleForm);
}
/**
* 获取角色表单数据
*
* @param roleId 角色ID
* @return {@link RoleForm} – 角色表单数据
*/
@Override
public RoleForm getRoleForm(Long roleId) {
SysRole entity = this.getById(roleId);
return roleConverter.entity2Form(entity);
}
修复建议
建议添加对当前用户身份的一些检查,确保非根用户无法访问到根用户的角色信息:
可尝试添加以下代码:
ne(!SecurityUtils.isRoot(), SysRole::getCode, SystemConstants.ROOT_ROLE_CODE)
或
Integer dataScope = roleService.getMaxDataRangeDataScope(roles);
问题描述
在SysRoleController.java中的getRoleForm函数及其callee"roleService.getRoleForm"函数未对当前用户的身份进行权限检查,可能导致当前非根用户通过直接输入根用户的Roleid的方式访问根用户角色信息:
修复建议
建议添加对当前用户身份的一些检查,确保非根用户无法访问到根用户的角色信息:
可尝试添加以下代码:
ne(!SecurityUtils.isRoot(), SysRole::getCode, SystemConstants.ROOT_ROLE_CODE)或
Integer dataScope = roleService.getMaxDataRangeDataScope(roles);