Skip to content

Commit d40820b

Browse files
committed
Merge branch '3.4'
2 parents af9e253 + bc84304 commit d40820b

File tree

60 files changed

+250
-117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+250
-117
lines changed

UPGRADE-3.4.md

+22
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,24 @@ FrameworkBundle
205205
`TranslationDebugCommand`, `TranslationUpdateCommand`, `XliffLintCommand`
206206
and `YamlLintCommand` classes have been marked as final
207207

208+
HttpFoundation
209+
--------------
210+
211+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`
212+
class has been deprecated and will be removed in 4.0. Use the `\SessionHandler` class instead.
213+
214+
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy` class has been
215+
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
216+
217+
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` class has been
218+
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
219+
220+
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` class has been
221+
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
222+
223+
* `NativeSessionStorage::setSaveHandler()` now takes an instance of `\SessionHandlerInterface` as argument.
224+
Not passing it is deprecated and will throw a `TypeError` in 4.0.
225+
208226
HttpKernel
209227
----------
210228

@@ -269,6 +287,10 @@ SecurityBundle
269287
as first argument. Not passing it is deprecated and will throw a `TypeError`
270288
in 4.0.
271289

290+
* Added `logout_on_user_change` to the firewall options. This config item will
291+
trigger a logout when the user has changed. Should be set to true to avoid
292+
deprecations in the configuration.
293+
272294
Translation
273295
-----------
274296

UPGRADE-4.0.md

+13
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,13 @@ HttpFoundation
524524
* The ability to check only for cacheable HTTP methods using `Request::isMethodSafe()` is
525525
not supported anymore, use `Request::isMethodCacheable()` instead.
526526

527+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`,
528+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy`,
529+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` and
530+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` classes have been removed.
531+
532+
* `NativeSessionStorage::setSaveHandler()` now requires an instance of `\SessionHandlerInterface` as argument.
533+
527534
HttpKernel
528535
----------
529536

@@ -642,6 +649,9 @@ Security
642649

643650
* Support for defining voters that don't implement the `VoterInterface` has been removed.
644651

652+
* Calling `ContextListener::setLogoutOnUserChange(false)` won't have any
653+
effect anymore.
654+
645655
SecurityBundle
646656
--------------
647657

@@ -660,6 +670,9 @@ SecurityBundle
660670
`Symfony\Component\Security\Acl\Model\MutableAclProviderInterfaceConnection`
661671
as first argument.
662672

673+
* The firewall option `logout_on_user_change` is now always true, which will
674+
trigger a logout if the user changes between requests.
675+
663676
Serializer
664677
----------
665678

src/Symfony/Bridge/Twig/Tests/AppVariableTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function testEnvironment()
4747

4848
public function testGetSession()
4949
{
50+
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
5051
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
51-
$request->method('getSession')->willReturn($session = new Session());
52+
$request->method('getSession')->willReturn($session);
5253

5354
$this->setRequestStack($request);
5455

@@ -167,8 +168,9 @@ public function testGetFlashesWithNoRequest()
167168

168169
public function testGetFlashesWithNoSessionStarted()
169170
{
171+
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
170172
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
171-
$request->method('getSession')->willReturn(new Session());
173+
$request->method('getSession')->willReturn($session);
172174

173175
$this->setRequestStack($request);
174176

@@ -257,7 +259,7 @@ private function setFlashMessages()
257259
$flashBag = new FlashBag();
258260
$flashBag->initialize($flashMessages);
259261

260-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock();
262+
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
261263
$session->method('isStarted')->willReturn(true);
262264
$session->method('getFlashBag')->willReturn($flashBag);
263265

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
</service>
3939

4040
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag" />
41+
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
4142

4243
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag" />
4344

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public function testRedirectToRoute()
376376
public function testAddFlash()
377377
{
378378
$flashBag = new FlashBag();
379-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock();
379+
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
380380
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
381381

382382
$container = new Container();

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ CHANGELOG
2222
* `SetAclCommand::__construct()` now takes an instance of
2323
`Symfony\Component\Security\Acl\Model\MutableAclProviderInterfaceConnection`
2424
as first argument
25+
* Added `logout_on_user_change` to the firewall options. This config item will
26+
trigger a logout when the user has changed. Should be set to true to avoid
27+
deprecations in the configuration.
2528

2629
3.3.0
2730
-----

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

+15
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
252252
->scalarNode('provider')->end()
253253
->booleanNode('stateless')->defaultFalse()->end()
254254
->scalarNode('context')->cannotBeEmpty()->end()
255+
->booleanNode('logout_on_user_change')
256+
->defaultFalse()
257+
->info('When true, it will trigger a logout for the user if something has changed. This will be the default behavior as of Syfmony 4.0.')
258+
->end()
255259
->arrayNode('logout')
256260
->treatTrueLike(array())
257261
->canBeUnset()
@@ -340,6 +344,17 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
340344
return $firewall;
341345
})
342346
->end()
347+
->validate()
348+
->ifTrue(function ($v) {
349+
return (isset($v['stateless']) && true === $v['stateless']) || (isset($v['security']) && false === $v['security']);
350+
})
351+
->then(function ($v) {
352+
// this option doesn't change behavior when true when stateless, so prevent deprecations
353+
$v['logout_on_user_change'] = true;
354+
355+
return $v;
356+
})
357+
->end()
343358
;
344359
}
345360

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ private function createFirewalls($config, ContainerBuilder $container)
228228
$providerIds = $this->createUserProviders($config, $container);
229229

230230
// make the ContextListener aware of the configured user providers
231-
$definition = $container->getDefinition('security.context_listener');
232-
$arguments = $definition->getArguments();
231+
$contextListenerDefinition = $container->getDefinition('security.context_listener');
232+
$arguments = $contextListenerDefinition->getArguments();
233233
$userProviders = array();
234234
foreach ($providerIds as $userProviderId) {
235235
$userProviders[] = new Reference($userProviderId);
236236
}
237237
$arguments[1] = new IteratorArgument($userProviders);
238-
$definition->setArguments($arguments);
238+
$contextListenerDefinition->setArguments($arguments);
239239

240240
$customUserChecker = false;
241241

@@ -247,6 +247,12 @@ private function createFirewalls($config, ContainerBuilder $container)
247247
$customUserChecker = true;
248248
}
249249

250+
if (!isset($firewall['logout_on_user_change']) || !$firewall['logout_on_user_change']) {
251+
@trigger_error('Setting logout_on_user_change to false is deprecated as of 3.4 and will always be true in 4.0. Set logout_on_user_change to true in your firewall configuration.', E_USER_DEPRECATED);
252+
}
253+
254+
$contextListenerDefinition->addMethodCall('setLogoutOnUserChange', array($firewall['logout_on_user_change']));
255+
250256
$configId = 'security.firewall.map.config.'.$name;
251257

252258
list($matcher, $listeners, $exceptionListener) = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $configId);

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php

+3
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,21 @@
7373
'logout' => true,
7474
'remember_me' => array('secret' => 'TheSecret'),
7575
'user_checker' => null,
76+
'logout_on_user_change' => true,
7677
),
7778
'host' => array(
7879
'pattern' => '/test',
7980
'host' => 'foo\\.example\\.org',
8081
'methods' => array('GET', 'POST'),
8182
'anonymous' => true,
8283
'http_basic' => true,
84+
'logout_on_user_change' => true,
8385
),
8486
'with_user_checker' => array(
8587
'user_checker' => 'app.user_checker',
8688
'anonymous' => true,
8789
'http_basic' => true,
90+
'logout_on_user_change' => true,
8891
),
8992
),
9093

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall_provider.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
'main' => array(
1616
'provider' => 'default',
1717
'form_login' => true,
18+
'logout_on_user_change' => true,
1819
),
1920
'other' => array(
2021
'provider' => 'with-dash',
2122
'form_login' => true,
23+
'logout_on_user_change' => true,
2224
),
2325
),
2426
));

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall_undefined_provider.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'main' => array(
1313
'provider' => 'undefined',
1414
'form_login' => true,
15+
'logout_on_user_change' => true,
1516
),
1617
),
1718
));

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/listener_provider.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'firewalls' => array(
1212
'main' => array(
1313
'form_login' => array('provider' => 'default'),
14+
'logout_on_user_change' => true,
1415
),
1516
),
1617
));

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/listener_undefined_provider.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'firewalls' => array(
1212
'main' => array(
1313
'form_login' => array('provider' => 'undefined'),
14+
'logout_on_user_change' => true,
1415
),
1516
),
1617
));

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'main' => array(
1212
'form_login' => false,
1313
'http_basic' => null,
14+
'logout_on_user_change' => true,
1415
),
1516
),
1617

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge_import.php

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'form_login' => array(
77
'login_path' => '/login',
88
),
9+
'logout_on_user_change' => true,
910
),
1011
),
1112
'role_hierarchy' => array(

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/no_custom_user_checker.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
),
1313
'firewalls' => array(
1414
'simple' => array('pattern' => '/login', 'security' => false),
15-
'secure' => array('stateless' => true,
15+
'secure' => array(
16+
'stateless' => true,
1617
'http_basic' => true,
1718
'http_digest' => array('secret' => 'TheSecret'),
1819
'form_login' => true,

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/remember_me_options.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'catch_exceptions' => false,
1414
'token_provider' => 'token_provider_id',
1515
),
16+
'logout_on_user_change' => true,
1617
),
1718
),
1819
));

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060
<remember-me secret="TheSecret"/>
6161
</firewall>
6262

63-
<firewall name="host" pattern="/test" host="foo\.example\.org" methods="GET,POST">
63+
<firewall name="host" pattern="/test" host="foo\.example\.org" methods="GET,POST" logout-on-user-change="true">
6464
<anonymous />
6565
<http-basic />
6666
</firewall>
6767

68-
<firewall name="with_user_checker">
68+
<firewall name="with_user_checker" logout-on-user-change="true">
6969
<anonymous />
7070
<http-basic />
7171
<user-checker>app.user_checker</user-checker>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall_provider.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</sec:providers>
1212

1313
<sec:firewalls>
14-
<sec:firewall name="main" provider="with-dash">
14+
<sec:firewall name="main" provider="with-dash" logout-on-user-change="true">
1515
<sec:form_login />
1616
</sec:firewall>
1717
</sec:firewalls>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall_undefined_provider.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</sec:providers>
1212

1313
<sec:firewalls>
14-
<sec:firewall name="main" provider="undefined">
14+
<sec:firewall name="main" provider="undefined" logout-on-user-change="true">
1515
<sec:form_login />
1616
</sec:firewall>
1717
</sec:firewalls>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/listener_provider.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</sec:providers>
1212

1313
<sec:firewalls>
14-
<sec:firewall name="main">
14+
<sec:firewall name="main" logout-on-user-change="true">
1515
<sec:form_login provider="default" />
1616
</sec:firewall>
1717
</sec:firewalls>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/listener_undefined_provider.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</sec:providers>
1212

1313
<sec:firewalls>
14-
<sec:firewall name="main">
14+
<sec:firewall name="main" logout-on-user-change="true">
1515
<sec:form_login provider="undefined" />
1616
</sec:firewall>
1717
</sec:firewalls>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<sec:config>
1313
<sec:provider name="default" id="foo" />
1414

15-
<sec:firewall name="main" form-login="false">
15+
<sec:firewall name="main" form-login="false" logout-on-user-change="true">
1616
<sec:http-basic />
1717
</sec:firewall>
1818

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge_import.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
77

88
<config>
9-
<firewall name="main">
9+
<firewall name="main" logout-on-user-change="true">
1010
<form-login login-path="/login" />
1111
</firewall>
1212

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/remember_me_options.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<sec:providers>
1010
<sec:default id="foo"/>
1111
</sec:providers>
12-
<sec:firewall name="main">
12+
<sec:firewall name="main" logout-on-user-change="true">
1313
<sec:form-login/>
1414
<sec:remember-me secret="TheSecret" catch-exceptions="false" token-provider="token_provider_id" />
1515
</sec:firewall>

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml

+2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ security:
6464
methods: [GET,POST]
6565
anonymous: true
6666
http_basic: true
67+
logout_on_user_change: true
6768

6869
with_user_checker:
6970
anonymous: ~
7071
http_basic: ~
7172
user_checker: app.user_checker
73+
logout_on_user_change: true
7274

7375
role_hierarchy:
7476
ROLE_ADMIN: ROLE_USER

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall_provider.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ security:
1111
main:
1212
provider: default
1313
form_login: true
14+
logout_on_user_change: true
1415
other:
1516
provider: with-dash
1617
form_login: true
18+
logout_on_user_change: true

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall_undefined_provider.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ security:
88
main:
99
provider: undefined
1010
form_login: true
11+
logout_on_user_change: true

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/listener_provider.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ security:
88
main:
99
form_login:
1010
provider: default
11+
logout_on_user_change: true

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/listener_undefined_provider.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ security:
88
main:
99
form_login:
1010
provider: undefined
11+
logout_on_user_change: true

0 commit comments

Comments
 (0)