Skip to content

Commit d351daa

Browse files
Merge branch '2.8' into 3.4
* 2.8: [travis][appveyor] use symfony/flex to accelerate builds [Security] Call AccessListener after LogoutListener
2 parents 1757c9c + 1d76f98 commit d351daa

File tree

9 files changed

+93
-11
lines changed

9 files changed

+93
-11
lines changed

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ before_install:
5959
6060
if [[ $TRAVIS_PHP_VERSION = 5.* || $TRAVIS_PHP_VERSION = hhvm* ]]; then
6161
composer () {
62-
$HOME/.phpenv/versions/7.1/bin/composer config platform.php $(echo ' <?php echo preg_replace("/-.*/", "", PHP_VERSION);' | php /dev/stdin)
62+
$HOME/.phpenv/versions/7.1/bin/php $HOME/.phpenv/versions/7.1/bin/composer config platform.php $(echo ' <?php echo preg_replace("/-.*/", "", PHP_VERSION);' | php /dev/stdin)
6363
$HOME/.phpenv/versions/7.1/bin/php $HOME/.phpenv/versions/7.1/bin/composer $*
6464
}
6565
export -f composer
@@ -209,6 +209,15 @@ install:
209209
SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
210210
fi
211211
212+
- |
213+
# Install symfony/flex
214+
if [[ $deps = low ]]; then
215+
export SYMFONY_REQUIRE='>=2.3'
216+
else
217+
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
218+
fi
219+
composer global require symfony/flex dev-master
220+
212221
- |
213222
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
214223
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]] && LEGACY=,legacy

appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ init:
1010
- SET PATH=c:\php;%PATH%
1111
- SET COMPOSER_NO_INTERACTION=1
1212
- SET SYMFONY_DEPRECATIONS_HELPER=strict
13+
- SET "SYMFONY_REQUIRE=>=3.4"
1314
- SET ANSICON=121x90 (121x90)
1415
- SET SYMFONY_PHPUNIT_VERSION=4.8
1516
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f
@@ -48,9 +49,10 @@ install:
4849
- copy /Y php.ini-min php.ini
4950
- echo extension=php_openssl.dll >> php.ini
5051
- cd c:\projects\symfony
51-
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar)
52+
- IF NOT EXIST composer.phar (appveyor DownloadFile https://github.com/composer/composer/releases/download/1.7.1/composer.phar)
5253
- php composer.phar self-update
5354
- copy /Y .composer\* %APPDATA%\Composer\
55+
- php composer.phar global require --no-progress symfony/flex dev-master
5456
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
5557
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
5658
- php composer.phar config platform.php 5.5.9

src/Symfony/Bundle/SecurityBundle/Tests/Functional/LogoutTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ public function testCsrfTokensAreClearedOnLogout()
4949

5050
$this->assertFalse(static::$kernel->getContainer()->get('test.security.csrf.token_storage')->hasToken('foo'));
5151
}
52+
53+
public function testAccessControlDoesNotApplyOnLogout()
54+
{
55+
$client = $this->createClient(array('test_case' => 'LogoutAccess', 'root_config' => 'config.yml'));
56+
57+
$client->request('POST', '/login', array('_username' => 'johannes', '_password' => 'test'));
58+
$client->request('GET', '/logout');
59+
60+
$this->assertRedirect($client->getResponse(), '/');
61+
}
5262
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
13+
use Symfony\Bundle\SecurityBundle\SecurityBundle;
14+
15+
return array(
16+
new FrameworkBundle(),
17+
new SecurityBundle(),
18+
);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
imports:
2+
- { resource: ./../config/framework.yml }
3+
4+
security:
5+
encoders:
6+
Symfony\Component\Security\Core\User\User: plaintext
7+
8+
providers:
9+
in_memory:
10+
memory:
11+
users:
12+
johannes: { password: test, roles: [ROLE_USER] }
13+
14+
firewalls:
15+
default:
16+
form_login:
17+
check_path: login
18+
remember_me: true
19+
require_previous_session: false
20+
logout: ~
21+
anonymous: ~
22+
stateless: true
23+
24+
access_control:
25+
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
26+
- { path: .*, roles: IS_AUTHENTICATED_FULLY }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
login:
2+
path: /login
3+
4+
logout:
5+
path: /logout

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^5.5.9|>=7.0.8",
2020
"ext-xml": "*",
21-
"symfony/security": "~3.4.12|~4.0.12|^4.1.1",
21+
"symfony/security": "~3.4.15|~4.0.15|^4.1.4",
2222
"symfony/dependency-injection": "^3.4.3|^4.0.3",
2323
"symfony/http-kernel": "~3.4|~4.0",
2424
"symfony/polyfill-php70": "~1.0"

src/Symfony/Component/Security/Http/Firewall.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
1717
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1818
use Symfony\Component\HttpKernel\KernelEvents;
19+
use Symfony\Component\Security\Http\Firewall\AccessListener;
1920

2021
/**
2122
* Firewall uses a FirewallMap to register security listeners for the given
@@ -49,20 +50,31 @@ public function onKernelRequest(GetResponseEvent $event)
4950
// register listeners for this firewall
5051
$listeners = $this->map->getListeners($event->getRequest());
5152

52-
$authenticationListeners = $listeners[0];
53-
$exceptionListener = $listeners[1];
54-
$logoutListener = isset($listeners[2]) ? $listeners[2] : null;
53+
$accessListener = null;
54+
$authenticationListeners = array();
5555

56-
if (null !== $exceptionListener) {
56+
foreach ($listeners[0] as $listener) {
57+
if ($listener instanceof AccessListener) {
58+
$accessListener = $listener;
59+
} else {
60+
$authenticationListeners[] = $listener;
61+
}
62+
}
63+
64+
if (null !== $exceptionListener = $listeners[1]) {
5765
$this->exceptionListeners[$event->getRequest()] = $exceptionListener;
5866
$exceptionListener->register($this->dispatcher);
5967
}
6068

61-
$this->handleRequest($event, $authenticationListeners);
69+
if (null !== $logoutListener = isset($listeners[2]) ? $listeners[2] : null) {
70+
$authenticationListeners[] = $logoutListener;
71+
}
6272

63-
if (null !== $logoutListener) {
64-
$logoutListener->handle($event);
73+
if (null !== $accessListener) {
74+
$authenticationListeners[] = $accessListener;
6575
}
76+
77+
$this->handleRequest($event, $authenticationListeners);
6678
}
6779

6880
public function onKernelFinishRequest(FinishRequestEvent $event)

src/Symfony/Component/Security/Http/Tests/FirewallTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse()
7979
->getMock()
8080
;
8181
$event
82-
->expects($this->once())
82+
->expects($this->at(0))
8383
->method('hasResponse')
8484
->will($this->returnValue(true))
8585
;

0 commit comments

Comments
 (0)