diff --git a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Languages.php b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Languages.php index 53e98e234dc..04a647c70fa 100644 --- a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Languages.php +++ b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Languages.php @@ -25,7 +25,7 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder) { $nodeBuilder ->arrayNode('languages') - ->cannotBeEmpty() + ->requiresAtLeastOneElement() ->info('Available languages, in order of precedence') ->example(array('fre-FR', 'eng-GB')) ->prototype('scalar')->end() diff --git a/eZ/Bundle/EzPublishDebugBundle/Collector/EzPublishCoreCollector.php b/eZ/Bundle/EzPublishDebugBundle/Collector/EzPublishCoreCollector.php index 3515ed979ba..2acc0e3d1c4 100644 --- a/eZ/Bundle/EzPublishDebugBundle/Collector/EzPublishCoreCollector.php +++ b/eZ/Bundle/EzPublishDebugBundle/Collector/EzPublishCoreCollector.php @@ -18,11 +18,7 @@ class EzPublishCoreCollector extends DataCollector { public function __construct() { - $this->data = [ - 'collectors' => [], - 'panelTemplates' => [], - 'toolbarTemplates' => [], - ]; + $this->reset(); } public function collect(Request $request, Response $response, \Exception $exception = null) @@ -104,4 +100,16 @@ public function getPanelTemplate($collectorName) return $this->data['panelTemplates'][$collectorName]; } + + /** + * {@inheritdoc} + */ + public function reset() + { + $this->data = [ + 'collectors' => [], + 'panelTemplates' => [], + 'toolbarTemplates' => [], + ]; + } } diff --git a/eZ/Bundle/EzPublishRestBundle/Resources/config/input_parsers.yml b/eZ/Bundle/EzPublishRestBundle/Resources/config/input_parsers.yml index d153a6ce6db..eee5d3a768f 100644 --- a/eZ/Bundle/EzPublishRestBundle/Resources/config/input_parsers.yml +++ b/eZ/Bundle/EzPublishRestBundle/Resources/config/input_parsers.yml @@ -327,7 +327,7 @@ services: ezpublish_rest.input.parser.URLWildcardCreate: parent: ezpublish_rest.input.parser - class: "%ezpublish_rest.input.parser.URLWildcardCreate.class%" + class: "%ezpublish_rest.input.parser.UrlWildcardCreate.class%" arguments: - "@ezpublish_rest.parser_tools" tags: diff --git a/eZ/Bundle/EzPublishRestBundle/Resources/config/security.yml b/eZ/Bundle/EzPublishRestBundle/Resources/config/security.yml index 4ad7ce893ad..cf928ee2649 100644 --- a/eZ/Bundle/EzPublishRestBundle/Resources/config/security.yml +++ b/eZ/Bundle/EzPublishRestBundle/Resources/config/security.yml @@ -18,3 +18,5 @@ services: ezpublish_rest.security.authentication.logout_handler: class: "%ezpublish_rest.security.authentication.logout_handler.class%" + arguments: + - '@ezpublish.config.resolver' diff --git a/eZ/Publish/Core/REST/Server/Security/RestLogoutHandler.php b/eZ/Publish/Core/REST/Server/Security/RestLogoutHandler.php index 7f86dee2953..d22fe7bb584 100644 --- a/eZ/Publish/Core/REST/Server/Security/RestLogoutHandler.php +++ b/eZ/Publish/Core/REST/Server/Security/RestLogoutHandler.php @@ -8,6 +8,7 @@ */ namespace eZ\Publish\Core\REST\Server\Security; +use eZ\Publish\Core\MVC\ConfigResolverInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; @@ -19,12 +20,41 @@ */ class RestLogoutHandler implements LogoutHandlerInterface { + /** + * @var \eZ\Publish\Core\MVC\ConfigResolverInterface + */ + private $configResolver; + + /** + * @param \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver + */ + public function __construct(ConfigResolverInterface $configResolver) + { + $this->configResolver = $configResolver; + } + + /** + * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Symfony\Component\HttpFoundation\Response $response + * @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token + */ public function logout(Request $request, Response $response, TokenInterface $token) { if (!$request->attributes->get('is_rest_request')) { return; } - $response->headers->clearCookie($request->getSession()->getName()); + $path = '/'; + $domain = null; + + $session = $this->configResolver->getParameter('session'); + if (array_key_exists('cookie_domain', $session)) { + $domain = $session['cookie_domain']; + } + if (array_key_exists('cookie_path', $session)) { + $path = $session['cookie_path']; + } + + $response->headers->clearCookie($request->getSession()->getName(), $path, $domain); } } diff --git a/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php b/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php index 6a36f55a288..2fc3a7cb2a9 100644 --- a/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php +++ b/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php @@ -8,6 +8,8 @@ */ namespace eZ\Publish\Core\REST\Server\Tests\Security; +use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; +use eZ\Publish\Core\MVC\ConfigResolverInterface; use eZ\Publish\Core\REST\Server\Security\RestLogoutHandler; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -18,27 +20,80 @@ class RestLogoutHandlerTest extends TestCase { - public function testLogout() + use PHPUnit5CompatTrait; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $configResolver; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $session; + + protected function setUp() + { + parent::setUp(); + $this->configResolver = $this->createMock(ConfigResolverInterface::class); + $this->session = $this->createMock(SessionInterface::class); + } + + public function testLogoutWithoutSiteaccessSessionSettings() { - $session = $this->createMock(SessionInterface::class); $sessionId = 'eZSESSID'; - $session + $this->session ->expects($this->once()) ->method('getName') ->will($this->returnValue($sessionId)); - $request = new Request(); - $request->setSession($session); + $request->setSession($this->session); $request->attributes->set('is_rest_request', true); - + $this->configResolver + ->expects($this->once()) + ->method('getParameter') + ->with('session') + ->will($this->returnValue([])); $response = new Response(); $response->headers = $this->createMock(ResponseHeaderBag::class); $response->headers ->expects($this->once()) ->method('clearCookie') ->with($sessionId); + $logoutHandler = new RestLogoutHandler($this->configResolver); + $logoutHandler->logout( + $request, + $response, + $this->createMock(TokenInterface::class) + ); + } - $logoutHandler = new RestLogoutHandler(); + public function testLogoutWithSiteaccessSessionSettings() + { + $sessionId = 'eZSESSID'; + $this->session + ->expects($this->once()) + ->method('getName') + ->will($this->returnValue($sessionId)); + $request = new Request(); + $request->setSession($this->session); + $request->attributes->set('is_rest_request', true); + $sessionSettings = [ + 'cookie_path' => '/', + 'cookie_domain' => 'ez.no', + ]; + $this->configResolver + ->expects($this->once()) + ->method('getParameter') + ->with('session') + ->will($this->returnValue($sessionSettings)); + $response = new Response(); + $response->headers = $this->createMock(ResponseHeaderBag::class); + $response->headers + ->expects($this->once()) + ->method('clearCookie') + ->with($sessionId, $sessionSettings['cookie_path'], $sessionSettings['cookie_domain']); + $logoutHandler = new RestLogoutHandler($this->configResolver); $logoutHandler->logout( $request, $response, @@ -62,7 +117,7 @@ public function testLogoutNotRest() ->expects($this->never()) ->method('clearCookie'); - $logoutHandler = new RestLogoutHandler(); + $logoutHandler = new RestLogoutHandler($this->configResolver); $logoutHandler->logout( $request, $response, diff --git a/eZ/Publish/Core/settings/fieldtype_external_storages.yml b/eZ/Publish/Core/settings/fieldtype_external_storages.yml index 1aa8a7d2f86..c2a4aa640d2 100644 --- a/eZ/Publish/Core/settings/fieldtype_external_storages.yml +++ b/eZ/Publish/Core/settings/fieldtype_external_storages.yml @@ -74,4 +74,4 @@ services: - {name: ezpublish.fieldType.externalStorageHandler, alias: ezuser} ezpublish.fieldType.metadataHandler.imagesize: - class: "%ezpublish.core.io.metadataHandler.imagesize.class%" + class: "%ezpublish.core.io.metadataHandler.imageSize.class%"