Skip to content

SysRoleController.java:getRoleForm函数未进行权限检查,可能导致非根用户直接访问根角色 #121

@old6ma

Description

@old6ma

问题描述
在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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions