Commit 8e23cf9c authored by Tino Goratsch's avatar Tino Goratsch

Merge branch 'hotfix/v4.28.1'

parents 19e103f2 39e228e6
Pipeline #28223647 passed with stages
in 8 minutes and 54 seconds
......@@ -8,14 +8,14 @@
namespace ACP3\Core;
use ACP3\Core\ACL\Model\Repository\UserRoleRepositoryInterface;
use ACP3\Core\ACL\PermissionCacheInterface;
use ACP3\Core\Authentication\Model\UserModelInterface;
use ACP3\Core\Controller\Helper\ControllerActionExists;
use ACP3\Modules\ACP3\Permissions;
use ACP3\Modules\ACP3\Users\Model\UserModel;
class ACL
{
/**
* @var \ACP3\Modules\ACP3\Users\Model\UserModel
* @var \ACP3\Core\Authentication\Model\UserModelInterface
*/
protected $user;
/**
......@@ -23,7 +23,7 @@ class ACL
*/
protected $modules;
/**
* @var \ACP3\Modules\ACP3\Permissions\Cache
* @var \ACP3\Core\ACL\PermissionCacheInterface
*/
protected $permissionsCache;
/**
......@@ -56,18 +56,18 @@ class ACL
/**
* ACL constructor.
*
* @param \ACP3\Modules\ACP3\Users\Model\UserModel $user
* @param \ACP3\Core\Authentication\Model\UserModelInterface $user
* @param \ACP3\Core\Modules $modules
* @param \ACP3\Core\Controller\Helper\ControllerActionExists $controllerActionExists
* @param \ACP3\Core\ACL\Model\Repository\UserRoleRepositoryInterface $userRoleRepository
* @param \ACP3\Modules\ACP3\Permissions\Cache $permissionsCache
* @param \ACP3\Core\ACL\PermissionCacheInterface $permissionsCache
*/
public function __construct(
UserModel $user,
UserModelInterface $user,
Modules $modules,
ControllerActionExists $controllerActionExists,
UserRoleRepositoryInterface $userRoleRepository,
Permissions\Cache $permissionsCache
PermissionCacheInterface $permissionsCache
) {
$this->user = $user;
$this->modules = $modules;
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL\Model\Repository;
interface PrivilegeRepositoryInterface
{
/**
* @return array
*/
public function getAllPrivilegeIds();
}
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL\Model\Repository;
interface RoleRepositoryInterface
{
/**
* @return array
*/
public function getAllRoles();
}
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL;
interface PermissionCacheInterface
{
/**
* @return array
*/
public function getResourcesCache();
/**
* Erstellt den Cache für alle existierenden Ressourcen.
*
* @return bool
*/
public function saveResourcesCache();
/**
* @return array
*/
public function getRolesCache();
/**
* Setzt den Cache für alle existierenden Rollen.
*
* @return bool
*/
public function saveRolesCache();
/**
* @param array $roles
*
* @return bool|mixed|string
*/
public function getRulesCache(array $roles);
/**
* Setzt den Cache für die einzelnen Berechtigungen einer Rolle.
*
* @param array $roles
*
* @return bool
*/
public function saveRulesCache(array $roles);
}
......@@ -7,7 +7,7 @@
namespace ACP3\Core\Application\BootstrapCache\Event\Listener;
use ACP3\Modules\ACP3\Users\Model\AuthenticationModel;
use ACP3\Core\Authentication\Model\AuthenticationModelInterface;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -27,9 +27,9 @@ class UserContextListener extends \FOS\HttpCache\SymfonyCache\UserContextListene
*/
protected function cleanupHashLookupRequest(Request $hashLookupRequest, Request $originalRequest)
{
$authCookie = $originalRequest->cookies->get(AuthenticationModel::AUTH_NAME);
$authCookie = $originalRequest->cookies->get(AuthenticationModelInterface::AUTH_NAME);
if ($authCookie !== null) {
$hashLookupRequest->cookies->set(AuthenticationModel::AUTH_NAME, $authCookie);
$hashLookupRequest->cookies->set(AuthenticationModelInterface::AUTH_NAME, $authCookie);
}
parent::cleanupHashLookupRequest($hashLookupRequest, $originalRequest);
......
......@@ -16,7 +16,7 @@ interface BootstrapInterface extends HttpKernelInterface
/**
* Contains the current ACP3 version string.
*/
const VERSION = '4.28.0';
const VERSION = '4.28.1';
/**
* Performs some startup checks.
......
......@@ -10,6 +10,7 @@ namespace ACP3\Core\Application\Event\Listener;
use ACP3\Core\ACL;
use ACP3\Core\ACL\Exception\AccessForbiddenException;
use ACP3\Core\Application\Event\ControllerActionBeforeDispatchEvent;
use ACP3\Core\Controller\AreaEnum;
class CheckPermissionListener
{
......@@ -30,6 +31,10 @@ class CheckPermissionListener
*/
public function __invoke(ControllerActionBeforeDispatchEvent $event)
{
if ($event->getArea() === AreaEnum::AREA_INSTALL) {
return;
}
$path = $event->getArea() . '/' . $event->getModule() . '/' . $event->getController() . '/' . $event->getControllerAction();
if ($this->acl->hasPermission($path) === false) {
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Authentication\Model;
use Symfony\Component\HttpFoundation\Cookie;
interface AuthenticationModelInterface
{
const AUTH_NAME = 'ACP3_AUTH';
/**
* Authenticates the user.
*
* @param array|int|null $userData
*/
public function authenticate($userData);
/**
* Logs out the current user.
*
* @param int $userId
*/
public function logout($userId = 0);
/**
* Setzt den internen Authentifizierungscookie.
*
* @param int $userId
* @param string $token
* @param int|null $expiry
*
* @return Cookie
*/
public function setRememberMeCookie($userId, $token, $expiry = null);
/**
* Loggt einen User ein.
*
* @param string $username
* @param string $password
* @param bool $rememberMe
*/
public function login($username, $password, $rememberMe);
}
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Authentication\Model;
interface UserModelInterface
{
/**
* Gibt ein Array mit den angeforderten Daten eines Benutzers zurück.
*
* @param int $userId
*
* @return array
*/
public function getUserInfo($userId = 0);
/**
* Returns, whether the current user is an authenticated user or not.
*
* @return bool
*/
public function isAuthenticated();
/**
* @param bool $isAuthenticated
*
* @return $this
*/
public function setIsAuthenticated($isAuthenticated);
/**
* Returns the user id of the currently logged in user.
*
* @return int
*/
public function getUserId();
/**
* @param int $userId
*
* @return $this
*/
public function setUserId($userId);
/**
* Returns, whether the currently logged in user is a super user or not.
*
* @return bool
*/
public function isSuperUser();
/**
* @param bool $isSuperUser
*
* @return $this
*/
public function setIsSuperUser($isSuperUser);
}
......@@ -27,7 +27,7 @@ abstract class AbstractWidgetAction implements ActionInterface
*/
protected $acl;
/**
* @var \ACP3\Modules\ACP3\Users\Model\UserModel
* @var \ACP3\Core\Authentication\Model\UserModelInterface
*/
protected $user;
/**
......
......@@ -8,6 +8,7 @@
namespace ACP3\Core\Controller\Context;
use ACP3\Core\ACL;
use ACP3\Core\Authentication\Model\UserModelInterface;
use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Helpers\ResultsPerPage;
use ACP3\Core\Http\RequestInterface;
......@@ -17,7 +18,6 @@ use ACP3\Core\Router\RouterInterface;
use ACP3\Core\Settings\SettingsInterface;
use ACP3\Core\Validation\Validator;
use ACP3\Core\View;
use ACP3\Modules\ACP3\Users\Model\UserModel;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;
......@@ -37,7 +37,7 @@ class WidgetContext
*/
protected $acl;
/**
* @var \ACP3\Modules\ACP3\Users\Model\UserModel
* @var \ACP3\Core\Authentication\Model\UserModelInterface
*/
protected $user;
/**
......@@ -87,7 +87,7 @@ class WidgetContext
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
* @param \ACP3\Core\ACL $acl
* @param \ACP3\Modules\ACP3\Users\Model\UserModel $user
* @param \ACP3\Core\Authentication\Model\UserModelInterface $user
* @param \ACP3\Core\I18n\Translator $translator
* @param \ACP3\Core\Modules $modules
* @param \ACP3\Core\Http\RequestInterface $request
......@@ -96,14 +96,14 @@ class WidgetContext
* @param \ACP3\Core\View $view
* @param \ACP3\Core\Settings\SettingsInterface $config
* @param \ACP3\Core\Environment\ApplicationPath $appPath
* @param Response $response
* @param ResultsPerPage $resultsPerPage
* @param \Symfony\Component\HttpFoundation\Response $response
* @param \ACP3\Core\Helpers\ResultsPerPage $resultsPerPage
*/
public function __construct(
ContainerInterface $container,
EventDispatcherInterface $eventDispatcher,
ACL $acl,
UserModel $user,
UserModelInterface $user,
Translator $translator,
Modules $modules,
RequestInterface $request,
......@@ -156,7 +156,7 @@ class WidgetContext
}
/**
* @return \ACP3\Modules\ACP3\Users\Model\UserModel
* @return \ACP3\Core\Authentication\Model\UserModelInterface
*/
public function getUser()
{
......
......@@ -46,7 +46,8 @@ class ServiceContainerBuilder extends ContainerBuilder
* @param string $applicationMode
*/
public function __construct(
ApplicationPath $applicationPath, SymfonyRequest $symfonyRequest, $applicationMode
ApplicationPath $applicationPath,
SymfonyRequest $symfonyRequest, $applicationMode
) {
parent::__construct();
......@@ -69,7 +70,7 @@ class ServiceContainerBuilder extends ContainerBuilder
'core.event_dispatcher',
'core.eventListener',
'core.eventSubscriber'
)
)
)
->addCompilerPass(new RegisterAuthenticationsCompilerPass())
->addCompilerPass(new RegisterSmartyPluginsPass())
......@@ -82,7 +83,6 @@ class ServiceContainerBuilder extends ContainerBuilder
$loader = new YamlFileLoader($this, new FileLocator(__DIR__));
$loader->load($this->applicationPath->getClassesDir() . 'config/services.yml');
$loader->load($this->applicationPath->getClassesDir() . 'View/Renderer/Smarty/config/services.yml');
// Try to get all available services
/** @var Modules $modules */
......
......@@ -9,7 +9,7 @@ namespace ACP3\Core;
use ACP3\Core\Controller\Helper\ControllerActionExists;
use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Modules\ModuleInfoCache;
use ACP3\Core\Modules\ModuleInfoCacheInterface;
use ACP3\Core\Modules\Vendor;
use MJS\TopSort\Implementations\StringSort;
......@@ -24,7 +24,7 @@ class Modules
*/
protected $controllerActionExists;
/**
* @var \ACP3\Core\Modules\ModuleInfoCache
* @var \ACP3\Core\Modules\ModuleInfoCacheInterface
*/
protected $moduleInfoCache;
/**
......@@ -41,15 +41,17 @@ class Modules
private $allModulesTopSorted = [];
/**
* Modules constructor.
*
* @param \ACP3\Core\Environment\ApplicationPath $appPath
* @param \ACP3\Core\Controller\Helper\ControllerActionExists $controllerActionExists
* @param \ACP3\Core\Modules\ModuleInfoCache $moduleInfoCache
* @param \ACP3\Core\Modules\ModuleInfoCacheInterface $moduleInfoCache
* @param \ACP3\Core\Modules\Vendor $vendors
*/
public function __construct(
ApplicationPath $appPath,
ControllerActionExists $controllerActionExists,
ModuleInfoCache $moduleInfoCache,
ModuleInfoCacheInterface $moduleInfoCache,
Vendor $vendors
) {
$this->appPath = $appPath;
......
......@@ -7,12 +7,14 @@
namespace ACP3\Core\Modules;
use ACP3\Core\ACL\Model\Repository\PrivilegeRepositoryInterface;
use ACP3\Core\ACL\Model\Repository\RoleRepositoryInterface;
use ACP3\Core\ACL\PermissionEnum;
use ACP3\Core\ACL\PrivilegeEnum;
use ACP3\Core\Cache;
use ACP3\Core\Controller\AreaEnum;
use ACP3\Core\Model\Repository\AbstractRepository;
use ACP3\Core\Modules\Installer\SchemaInterface;
use ACP3\Modules\ACP3\Permissions;
class AclInstaller implements InstallerInterface
{
......@@ -28,37 +30,39 @@ class AclInstaller implements InstallerInterface
*/
private $schemaHelper;
/**
* @var \ACP3\Modules\ACP3\Permissions\Model\Repository\RoleRepository
* @var \ACP3\Core\ACL\Model\Repository\RoleRepositoryInterface
*/
private $roleRepository;
/**
* @var \ACP3\Modules\ACP3\Permissions\Model\Repository\PrivilegeRepository
* @var \ACP3\Core\ACL\Model\Repository\PrivilegeRepositoryInterface
*/
private $privilegeRepository;
/**
* @var \ACP3\Modules\ACP3\Permissions\Model\Repository\ResourceRepository
* @var \ACP3\Core\Model\Repository\AbstractRepository
*/
private $resourceRepository;
/**
* @var \ACP3\Modules\ACP3\Permissions\Model\Repository\RuleRepository
* @var \ACP3\Core\Model\Repository\AbstractRepository
*/
private $ruleRepository;
/**
* @param \ACP3\Core\Cache $aclCache
* @param \ACP3\Core\Modules\SchemaHelper $schemaHelper
* @param \ACP3\Modules\ACP3\Permissions\Model\Repository\RoleRepository $roleRepository
* @param \ACP3\Modules\ACP3\Permissions\Model\Repository\RuleRepository $ruleRepository
* @param \ACP3\Modules\ACP3\Permissions\Model\Repository\ResourceRepository $resourceRepository
* @param \ACP3\Modules\ACP3\Permissions\Model\Repository\PrivilegeRepository $privilegeRepository
* AclInstaller constructor.
*
* @param \ACP3\Core\Cache $aclCache
* @param \ACP3\Core\Modules\SchemaHelper $schemaHelper
* @param \ACP3\Core\ACL\Model\Repository\RoleRepositoryInterface $roleRepository
* @param \ACP3\Core\Model\Repository\AbstractRepository $ruleRepository
* @param \ACP3\Core\Model\Repository\AbstractRepository $resourceRepository
* @param \ACP3\Core\ACL\Model\Repository\PrivilegeRepositoryInterface $privilegeRepository
*/
public function __construct(
Cache $aclCache,
SchemaHelper $schemaHelper,
Permissions\Model\Repository\RoleRepository $roleRepository,
Permissions\Model\Repository\RuleRepository $ruleRepository,
Permissions\Model\Repository\ResourceRepository $resourceRepository,
Permissions\Model\Repository\PrivilegeRepository $privilegeRepository
RoleRepositoryInterface $roleRepository,
AbstractRepository $ruleRepository,
AbstractRepository $resourceRepository,
PrivilegeRepositoryInterface $privilegeRepository
) {
$this->aclCache = $aclCache;
$this->schemaHelper = $schemaHelper;
......@@ -75,6 +79,8 @@ class AclInstaller implements InstallerInterface
* @param int $mode
*
* @return bool
*
* @throws \Doctrine\DBAL\DBALException
*/
public function install(SchemaInterface $schema, $mode = self::INSTALL_RESOURCES_AND_RULES)
{
......@@ -93,6 +99,8 @@ class AclInstaller implements InstallerInterface
* Inserts a new resource into the database.
*
* @param SchemaInterface $schema
*
* @throws \Doctrine\DBAL\DBALException
*/
private function insertAclResources(SchemaInterface $schema)
{
......@@ -127,6 +135,8 @@ class AclInstaller implements InstallerInterface
* Insert new acl user rules.
*
* @param string $moduleName
*
* @throws \Doctrine\DBAL\DBALException
*/
private function insertAclRules($moduleName)
{
......
......@@ -13,7 +13,7 @@ use ACP3\Core\Filesystem;
use ACP3\Core\Model\Repository\ModuleAwareRepositoryInterface;
use ACP3\Core\XML;
class ModuleInfoCache
class ModuleInfoCache implements ModuleInfoCacheInterface
{
use ModuleDependenciesTrait;
......@@ -64,7 +64,7 @@ class ModuleInfoCache
/**
* @return string
*/
public function getCacheKey(): string
protected function getCacheKey(): string
{
return 'modules_info';
}
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Modules;
interface ModuleInfoCacheInterface
{
/**
* @return array
*/
public function getModulesInfoCache(): array;
/**
* Saves the modules info cache.
*/
public function saveModulesInfoCache(): void;
}
......@@ -8,10 +8,9 @@
namespace ACP3\Core\Test;
use ACP3\Core\ACL;
use ACP3\Core\Authentication\Model\UserModelInterface;
use ACP3\Core\Controller\Helper\ControllerActionExists;
use ACP3\Core\Modules;
use ACP3\Modules\ACP3\Permissions\Cache;
use ACP3\Modules\ACP3\Users\Model\UserModel;
class ACLTest extends \PHPUnit_Framework_TestCase
{
......@@ -55,11 +54,11 @@ class ACLTest extends \PHPUnit_Framework_TestCase
private function initializeMockObjects()
{
$this->userMock = $this->createMock(UserModel::class);
$this->userMock = $this->createMock(UserModelInterface::class);
$this->modulesMock = $this->createMock(Modules::class);
$this->controllerActionExistsMock = $this->createMock(ControllerActionExists::class);
$this->userRoleRepositoryMock = $this->createMock(ACL\Model\Repository\UserRoleRepositoryInterface::class);
$this->permissionsCacheMock = $this->createMock(Cache::class);
$this->permissionsCacheMock = $this->createMock(ACL\PermissionCacheInterface::class);
}
public function testGetUserRoleIdsForGuest()
......
......@@ -10,38 +10,3 @@ services:
core.application.argument_resolver:
class: Symfony\Component\HttpKernel\Controller\ArgumentResolver
core.application.event.add_esi_surrogate_header_listener:
class: ACP3\Core\Application\Event\Listener\AddEsiSurrogateHeaderListener
arguments:
- '@core.http.request'
tags:
- { name: core.eventListener, event: core.application.controller_action_dispatcher.after_dispatch, method: execute }
core.application.event.add_template_variables_listener:
class: ACP3\Core\Application\Event\Listener\AddTemplateVariablesListener
arguments:
- '@core.environment.application_path'
- '@core.http.request'
- '@core.environment.theme'
- '@core.view'
- '@core.i18n.translator'
tags:
- { name: core.eventListener, event: core.application.controller_action_dispatcher.before_dispatch }
core.application.event.check_maintenance_mode_listener:
class: ACP3\Core\Application\Event\Listener\CheckMaintenanceModeListener
arguments:
- '@core.environment.application_path'
- '@core.http.request'
- '@core.config'
- '@core.view'
tags:
- { name: core.eventListener, event: core.application.controller_action_dispatcher.before_dispatch }
core.application.event.check_permission_listener:
class: ACP3\Core\Application\Event\Listener\CheckPermissionListener
arguments:
- '@core.acl'
tags:
- { name: core.eventListener, event: core.application.controller_action_dispatcher.before_dispatch }
services:
core.context.widget:
class: ACP3\Core\Controller\Context\WidgetContext
arguments:
- '@service_container'
- '@core.event_dispatcher'
- '@core.acl'
- '@users.model.user_model'
- '@core.i18n.translator'
- '@core.modules'
- '@core.http.request'
- '@core.router'
- '@core.validator'
- '@core.view'
- '@core.config'
- '@core.environment.application_path'
- '@core.http.response'
- '@core.helpers.results_per_page'
core.context.admin:
class: ACP3\Core\Controller\Context\AdminContext
parent: core.context.frontend
deprecated: 'The "%service_id%" service is deprecated. Use "core.context.frontend" instead'
core.context.frontend:
class: ACP3\Core\Controller\Context\FrontendContext
arguments:
- '@core.context.widget'
- '@core.assets'
- '@core.breadcrumb'
- '@core.breadcrumb.title'
- '@core.modules.helper.action'
- '@core.helpers.redirect'
- '@core.http.redirect_response'
services:
core.context.widget:
class: ACP3\Core\Controller\Context\WidgetContext
arguments:
- '@service_container'
- '@core.event_dispatcher'
- '@core.acl'
- '@users.model.user_model'
- '@core.i18n.translator'
- '@core.modules'
- '@core.http.request'
- '@core.router'
- '@core.validator'
- '@core.view'
- '@core.config'
- '@core.environment.application_path'
- '@core.http.response'
- '@core.helpers.results_per_page'
core.context.admin:
class: ACP3\Core\Controller\Context\AdminContext
parent: core.context.frontend
deprecated: 'The "%service_id%" service is deprecated. Use "core.context.frontend" instead'
core.context.frontend:
class: ACP3\Core\Controller\Context\FrontendContext
arguments:
- '@core.context.widget'
- '@core.assets'