new api 2.0

This commit is contained in:
daniel 2024-01-31 11:56:11 +01:00
parent 10ee8f572a
commit 280e5e5a97
18 changed files with 92 additions and 24 deletions

View File

@ -507,14 +507,16 @@ if (enterprise_installed()) {
// Read configuration file.
$files = config_agents_get_agent_config_filenames($id_agente);
$file_name = $files['conf'];
$agent_config = file_get_contents($file_name);
$encoding = 'UTF-8';
$agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding);
if ($agent_config_utf8 !== false) {
$agent_config = $agent_config_utf8;
}
if (empty($file_name) === false) {
$agent_config = file_get_contents($file_name);
$encoding = 'UTF-8';
$agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding);
if ($agent_config_utf8 !== false) {
$agent_config = $agent_config_utf8;
}
$broker = str_contains($agent_config, '#broker active');
$broker = str_contains($agent_config, '#broker active');
}
}
if ($broker === false) {

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Groups\Controllers;
use PandoraFMS\Modules\Groups\Actions\CreateGroupAction;
use PandoraFMS\Modules\Groups\Entities\Group;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -15,6 +16,7 @@ final class CreateGroupController extends Controller
public function __construct(
private CreateGroupAction $createGroupAction,
private ValidateAclSystem $acl,
private Management $management
) {
}
@ -40,6 +42,8 @@ final class CreateGroupController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user for groups');
$this->management->isManagementAllowed('Group', true);
$result = $this->createGroupAction->__invoke($group);
return $this->getResponse($response, $result);

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Groups\Controllers;
use PandoraFMS\Modules\Groups\Actions\DeleteGroupAction;
use PandoraFMS\Modules\Groups\Actions\GetGroupAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -15,7 +16,8 @@ final class DeleteGroupController extends Controller
public function __construct(
private DeleteGroupAction $deleteGroupAction,
private ValidateAclSystem $acl,
private GetGroupAction $getGroupAction
private GetGroupAction $getGroupAction,
private Management $management
) {
}
@ -41,6 +43,8 @@ final class DeleteGroupController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user for groups');
$this->management->isManagementAllowed('Group', true);
$result = $this->deleteGroupAction->__invoke($group);
return $this->getResponse($response, $result);
}

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Groups\Controllers;
use PandoraFMS\Modules\Groups\Actions\GetGroupAction;
use PandoraFMS\Modules\Groups\Actions\UpdateGroupAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -31,7 +32,8 @@ final class UpdateGroupController extends Controller
public function __construct(
private UpdateGroupAction $updateGroupAction,
private ValidateAclSystem $acl,
private GetGroupAction $getGroupAction
private GetGroupAction $getGroupAction,
private Management $management
) {
}
@ -46,6 +48,8 @@ final class UpdateGroupController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user for groups');
$this->management->isManagementAllowed('Group', true);
$result = $this->updateGroupAction->__invoke($group, $oldGroup);
return $this->getResponse($response, $result);
}

View File

@ -124,8 +124,8 @@ final class GroupFilter extends FilterAbstract
public function getFieldsFreeSearch(): ?array
{
return [
GroupDataMapper::NAME,
GroupDataMapper::DESCRIPTION,
GroupDataMapper::TABLE_NAME.'.'.GroupDataMapper::NAME,
GroupDataMapper::TABLE_NAME.'.'.GroupDataMapper::DESCRIPTION,
];
}
}

View File

@ -159,6 +159,8 @@ class GroupRepositoryMySQL extends RepositoryMySQL implements GroupRepository
$pagination
);
hd($sql, true);
return $sql;
}
}

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\CreateProfileAction;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -15,6 +16,7 @@ final class CreateProfileController extends Controller
public function __construct(
private CreateProfileAction $createProfileAction,
private ValidateAclSystem $acl,
private Management $management
) {
}
@ -41,6 +43,10 @@ final class CreateProfileController extends Controller
$this->acl->validateUserAdmin();
$this->acl->validate(0, 'UM', ' tried to manage profile');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('Profile', true);
}
$result = $this->createProfileAction->__invoke($profile);
return $this->getResponse($response, $result);

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\DeleteProfileAction;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -15,7 +16,8 @@ final class DeleteProfileController extends Controller
public function __construct(
private DeleteProfileAction $deleteProfileAction,
private ValidateAclSystem $acl,
private GetProfileAction $getProfileAction
private GetProfileAction $getProfileAction,
private Management $management
) {
}
@ -42,6 +44,10 @@ final class DeleteProfileController extends Controller
$this->acl->validateUserAdmin();
$this->acl->validate(0, 'UM', ' tried to manage profile');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('Profile', true);
}
$result = $this->deleteProfileAction->__invoke($profile);
return $this->getResponse($response, $result);
}

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Profiles\Actions\UpdateProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -31,7 +32,8 @@ final class UpdateProfileController extends Controller
public function __construct(
private UpdateProfileAction $updateProfileAction,
private ValidateAclSystem $acl,
private GetProfileAction $getProfileAction
private GetProfileAction $getProfileAction,
private Management $management
) {
}
@ -47,6 +49,10 @@ final class UpdateProfileController extends Controller
$this->acl->validateUserAdmin();
$this->acl->validate(0, 'UM', ' tried to manage profile');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('Profile', true);
}
$result = $this->updateProfileAction->__invoke($profile, $oldProfile);
return $this->getResponse($response, $result);
}

View File

@ -5,6 +5,7 @@ namespace PandoraFMS\Modules\Tags\Controllers;
use PandoraFMS\Modules\Tags\Actions\CreateTagAction;
use PandoraFMS\Modules\Tags\Entities\Tag;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
@ -15,6 +16,7 @@ final class CreateTagController extends Controller
public function __construct(
private CreateTagAction $createTagAction,
private ValidateAclSystem $acl,
private Management $management
) {
}
@ -40,6 +42,8 @@ final class CreateTagController extends Controller
$this->acl->validate(0, 'PM', ' tried to manage tag');
$this->management->isManagementAllowed('Tag', true);
$result = $this->createTagAction->__invoke($tag);
return $this->getResponse($response, $result);

View File

@ -2,10 +2,11 @@
namespace PandoraFMS\Modules\Tags\Controllers;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Tags\Actions\DeleteTagAction;
use PandoraFMS\Modules\Tags\Actions\GetTagAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
@ -15,7 +16,8 @@ final class DeleteTagController extends Controller
public function __construct(
private DeleteTagAction $deleteTagAction,
private ValidateAclSystem $acl,
private GetTagAction $getTagAction
private GetTagAction $getTagAction,
private Management $management
) {
}
@ -41,6 +43,8 @@ final class DeleteTagController extends Controller
$this->acl->validate(0, 'PM', ' tried to manage tag');
$this->management->isManagementAllowed('Tag', true);
$result = $this->deleteTagAction->__invoke($tag);
return $this->getResponse($response, $result);
}

View File

@ -2,10 +2,11 @@
namespace PandoraFMS\Modules\Tags\Controllers;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Tags\Actions\GetTagAction;
use PandoraFMS\Modules\Tags\Actions\UpdateTagAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
@ -31,7 +32,8 @@ final class UpdateTagController extends Controller
public function __construct(
private UpdateTagAction $updateTagAction,
private ValidateAclSystem $acl,
private GetTagAction $getTagAction
private GetTagAction $getTagAction,
private Management $management
) {
}
@ -46,6 +48,8 @@ final class UpdateTagController extends Controller
$this->acl->validate(0, 'PM', ' tried to manage tag');
$this->management->isManagementAllowed('Tag', true);
$result = $this->updateTagAction->__invoke($tag, $oldTag);
return $this->getResponse($response, $result);
}

View File

@ -42,7 +42,9 @@ final class CreateUserController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user');
$this->management->isManagementAllowed('User');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('User', true);
}
$result = $this->createUserAction->__invoke($user);

View File

@ -43,7 +43,9 @@ final class DeleteUserController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user');
$this->management->isManagementAllowed('User');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('User');
}
$result = $this->deleteUserAction->__invoke($user);
return $this->getResponse($response, $result);

View File

@ -35,7 +35,11 @@ final class GetUserController extends Controller
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'idUser');
$this->acl->validate(0, 'UM', ' tried to manage user');
$result = $this->getUserAction->__invoke($idUser);
return $this->getResponse($response, $result);
}
}

View File

@ -48,7 +48,9 @@ final class UpdateUserController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user');
$this->management->isManagementAllowed('User');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('User');
}
$result = $this->updateUserAction->__invoke($user, $oldUser);
return $this->getResponse($response, $result);

View File

@ -4,6 +4,7 @@ namespace PandoraFMS\Modules\Users\UserProfiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Users\Actions\GetUserAction;
use PandoraFMS\Modules\Users\UserProfiles\Actions\CreateUserProfileAction;
@ -18,7 +19,8 @@ final class CreateUserProfileController extends Controller
private CreateUserProfileAction $createUserProfileAction,
private ValidateAclSystem $acl,
private GetUserAction $getUserAction,
private GetProfileAction $getProfileAction
private GetProfileAction $getProfileAction,
private Management $management
) {
}
@ -46,6 +48,10 @@ final class CreateUserProfileController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user profile');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('User profile', true);
}
$idProfile = $this->getParam($request, 'idProfile');
$this->getProfileAction->__invoke($idProfile);

View File

@ -4,6 +4,7 @@ namespace PandoraFMS\Modules\Users\UserProfiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\Management;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Users\Actions\GetUserAction;
use PandoraFMS\Modules\Users\UserProfiles\Actions\DeleteUserProfileAction;
@ -19,7 +20,8 @@ final class DeleteUserProfileController extends Controller
private ValidateAclSystem $acl,
private GetUserAction $getUserAction,
private GetProfileAction $getProfileAction,
private GetUserProfileAction $getUserProfileAction
private GetUserProfileAction $getUserProfileAction,
private Management $management
) {
}
@ -46,6 +48,10 @@ final class DeleteUserProfileController extends Controller
$this->acl->validate(0, 'UM', ' tried to manage user profile');
if (\is_metaconsole() === false) {
$this->management->isManagementAllowed('User profile', true);
}
$idProfile = $this->getParam($request, 'idProfile');
$profile = $this->getProfileAction->__invoke($idProfile);