Check for permissions to access settings menu and added settings menu to sidebar menu

This commit is contained in:
Jan Böhmer 2025-07-06 22:29:35 +02:00
parent b9c3358f7f
commit 38c826713f
5 changed files with 31 additions and 14 deletions

View file

@ -40,6 +40,8 @@ class SettingsController extends AbstractController
#[Route("/settings", name: "system_settings")]
public function systemSettings(Request $request, TagAwareCacheInterface $cache): Response
{
$this->denyAccessUnlessGranted('@config.change_system_settings');
//Create a clone of the settings object
$settings = $this->settingsManager->createTemporaryCopy(AppSettings::class);
@ -62,9 +64,6 @@ class SettingsController extends AbstractController
$cache->invalidateTags(['tree_treeview', 'sidebar_tree_update']);
}
//Render the form
return $this->render('settings/settings.html.twig', [
'form' => $form

View file

@ -289,6 +289,13 @@ class ToolsTreeBuilder
))->setIcon('fa-fw fa-treeview fa-solid fa-database');
}
if ($this->security->isGranted('@config.change_system_settings')) {
$nodes[] = (new TreeViewNode(
$this->translator->trans('tree.tools.system.settings'),
$this->urlGenerator->generate('system_settings')
))->setIcon('fa fa-fw fa-gears fa-solid');
}
return $nodes;
}
}

View file

@ -105,6 +105,9 @@ class PermissionPresetsHelper
$this->permissionResolver->setAllOperationsOfPermission($perm_holder, 'suppliers', PermissionData::ALLOW);
$this->permissionResolver->setAllOperationsOfPermission($perm_holder, 'projects', PermissionData::ALLOW);
//Allow to change system settings
$this->permissionResolver->setPermission($perm_holder, 'config', 'change_system_settings', PermissionData::ALLOW);
//Allow to manage Oauth tokens
$this->permissionResolver->setPermission($perm_holder, 'system', 'manage_oauth_tokens', PermissionData::ALLOW);
//Allow to show updates