Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3e1080

Browse files
committed
Fix CookieClearingLogoutListener DI configuration
1 parent 8bb0897 commit e3e1080

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<service id="security.logout.listener.session" class="Symfony\Component\Security\Http\EventListener\SessionLogoutListener" abstract="true" />
5656

57-
<service id="security.logout.listener.cookie_clearing" class="Symfony\Component\Security\Http\Logout\CookieClearingLogoutHandler" abstract="true" />
57+
<service id="security.logout.listener.cookie_clearing" class="Symfony\Component\Security\Http\EventListener\CookieClearingLogoutListener" abstract="true" />
5858

5959
<service id="security.logout.listener.default" class="Symfony\Component\Security\Http\EventListener\DefaultLogoutListener" abstract="true">
6060
<argument type="service" id="security.http_utils" />

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14+
use Symfony\Component\BrowserKit\Cookie;
15+
1416
class LogoutTest extends AbstractWebTestCase
1517
{
1618
/**
@@ -62,11 +64,24 @@ public function testCsrfTokensAreClearedOnLogout(array $options)
6264
*/
6365
public function testAccessControlDoesNotApplyOnLogout(array $options)
6466
{
65-
$client = $this->createClient($options + ['test_case' => 'LogoutAccess', 'root_config' => 'config.yml']);
67+
$client = $this->createClient($options + ['test_case' => 'Logout', 'root_config' => 'config_access.yml']);
6668

6769
$client->request('POST', '/login', ['_username' => 'johannes', '_password' => 'test']);
6870
$client->request('GET', '/logout');
6971

7072
$this->assertRedirect($client->getResponse(), '/');
7173
}
74+
75+
public function testCookieClearingOnLogout()
76+
{
77+
$client = $this->createClient(['test_case' => 'Logout', 'root_config' => 'config_cookie_clearing.yml']);
78+
79+
$client->request('POST', '/login', ['_username' => 'johannes', '_password' => 'test']);
80+
$client->request('GET', '/logout');
81+
82+
$cookieJar = $client->getCookieJar();
83+
$cookieJar->set(new Cookie('flavor', 'chocolate', strtotime('+1 day')));
84+
85+
$this->assertRedirect($client->getResponse(), '/');
86+
}
7287
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
delete_cookies:
22+
flavor: { path: null, domain: null }
23+
stateless: true
24+
25+
access_control:
26+
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
27+
- { path: .*, roles: IS_AUTHENTICATED_FULLY }

0 commit comments

Comments
 (0)