Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f09ccf4

Browse filesBrowse files
committed
[SecurityBundle] Fix FirewallConfig nullable arguments
Nullable arguments were replaced by empty string by the DIC config if values weren't replaced in the extension.
1 parent 59f9949 commit f09ccf4
Copy full SHA for f09ccf4

File tree

6 files changed

+27
-22
lines changed
Filter options

6 files changed

+27
-22
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
267267
{
268268
$config = $container->setDefinition($configId, new DefinitionDecorator('security.firewall.config'));
269269
$config->replaceArgument(0, $id);
270+
$config->replaceArgument(1, $firewall['user_checker']);
270271

271272
// Matcher
272273
$matcher = null;
@@ -279,8 +280,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
279280
$matcher = $this->createRequestMatcher($container, $pattern, $host, $methods);
280281
}
281282

282-
$config->replaceArgument(1, (string) $matcher);
283-
$config->replaceArgument(2, $firewall['user_checker']);
283+
$config->replaceArgument(2, $matcher ? (string) $matcher : null);
284284
$config->replaceArgument(3, $firewall['security']);
285285

286286
// Security disabled?
@@ -306,18 +306,19 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
306306
// Channel listener
307307
$listeners[] = new Reference('security.channel_listener');
308308

309+
$contextKey = null;
309310
// Context serializer listener
310311
if (false === $firewall['stateless']) {
311312
$contextKey = $id;
312313
if (isset($firewall['context'])) {
313314
$contextKey = $firewall['context'];
314315
}
315316

316-
$config->replaceArgument(6, $contextKey);
317-
318317
$listeners[] = new Reference($this->createContextListener($container, $contextKey));
319318
}
320319

320+
$config->replaceArgument(6, $contextKey);
321+
321322
// Logout listener
322323
if (isset($firewall['logout'])) {
323324
$listenerKeys[] = 'logout';
@@ -399,12 +400,8 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
399400
// Exception listener
400401
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless']));
401402

402-
if (isset($firewall['access_denied_handler'])) {
403-
$config->replaceArgument(8, $firewall['access_denied_handler']);
404-
}
405-
if (isset($firewall['access_denied_url'])) {
406-
$config->replaceArgument(9, $firewall['access_denied_url']);
407-
}
403+
$config->replaceArgument(8, isset($firewall['access_denied_handler']) ? $firewall['access_denied_handler'] : null);
404+
$config->replaceArgument(9, isset($firewall['access_denied_url']) ? $firewall['access_denied_url'] : null);
408405

409406
$container->setAlias(new Alias('security.user_checker.'.$id, false), $firewall['user_checker']);
410407

‎src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@
116116

117117
<service id="security.firewall.config" class="Symfony\Bundle\SecurityBundle\Security\FirewallConfig" abstract="true" public="false">
118118
<argument /> <!-- name -->
119-
<argument /> <!-- request_matcher -->
120119
<argument /> <!-- user_checker -->
120+
<argument /> <!-- request_matcher -->
121121
<argument /> <!-- security enabled -->
122122
<argument /> <!-- stateless -->
123123
<argument /> <!-- provider -->

‎src/Symfony/Bundle/SecurityBundle/Security/FirewallConfig.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Security/FirewallConfig.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
final class FirewallConfig
1818
{
1919
private $name;
20-
private $requestMatcher;
2120
private $userChecker;
21+
private $requestMatcher;
2222
private $securityEnabled;
2323
private $stateless;
2424
private $provider;
@@ -30,8 +30,8 @@ final class FirewallConfig
3030

3131
/**
3232
* @param string $name
33-
* @param string $requestMatcher
3433
* @param string $userChecker
34+
* @param string|null $requestMatcher
3535
* @param bool $securityEnabled
3636
* @param bool $stateless
3737
* @param string|null $provider
@@ -41,11 +41,11 @@ final class FirewallConfig
4141
* @param string|null $accessDeniedUrl
4242
* @param string[] $listeners
4343
*/
44-
public function __construct($name, $requestMatcher, $userChecker, $securityEnabled = true, $stateless = false, $provider = null, $context = null, $entryPoint = null, $accessDeniedHandler = null, $accessDeniedUrl = null, $listeners = array())
44+
public function __construct($name, $userChecker, $requestMatcher = null, $securityEnabled = true, $stateless = false, $provider = null, $context = null, $entryPoint = null, $accessDeniedHandler = null, $accessDeniedUrl = null, $listeners = array())
4545
{
4646
$this->name = $name;
47-
$this->requestMatcher = $requestMatcher;
4847
$this->userChecker = $userChecker;
48+
$this->requestMatcher = $requestMatcher;
4949
$this->securityEnabled = $securityEnabled;
5050
$this->stateless = $stateless;
5151
$this->provider = $provider;
@@ -62,7 +62,8 @@ public function getName()
6262
}
6363

6464
/**
65-
* @return string The request matcher service id
65+
* @return string|null The request matcher service id or null if neither the request matcher, pattern or host
66+
* options were provided
6667
*/
6768
public function getRequestMatcher()
6869
{

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,21 @@ public function testFirewalls()
7878
$this->assertEquals(array(
7979
array(
8080
'simple',
81-
'security.request_matcher.707b20193d4cb9f2718114abcbebb32af48f948484fc166a03482f49bf14f25e271f72c7',
8281
'security.user_checker',
82+
'security.request_matcher.707b20193d4cb9f2718114abcbebb32af48f948484fc166a03482f49bf14f25e271f72c7',
8383
false,
8484
),
8585
array(
8686
'secure',
87-
'',
8887
'security.user_checker',
88+
null,
8989
true,
9090
true,
9191
'security.user.provider.concrete.default',
92+
null,
9293
'security.authentication.form_entry_point.secure',
94+
null,
95+
null,
9396
array(
9497
'logout',
9598
'switch_user',
@@ -104,27 +107,31 @@ public function testFirewalls()
104107
),
105108
array(
106109
'host',
107-
'security.request_matcher.dda8b565689ad8509623ee68fb2c639cd81cd4cb339d60edbaf7d67d30e6aa09bd8c63c3',
108110
'security.user_checker',
111+
'security.request_matcher.dda8b565689ad8509623ee68fb2c639cd81cd4cb339d60edbaf7d67d30e6aa09bd8c63c3',
109112
true,
110113
false,
111114
'security.user.provider.concrete.default',
112115
'host',
113116
'security.authentication.basic_entry_point.host',
117+
null,
118+
null,
114119
array(
115120
'http_basic',
116121
'anonymous',
117122
),
118123
),
119124
array(
120125
'with_user_checker',
121-
'',
122126
'app.user_checker',
127+
null,
123128
true,
124129
false,
125130
'security.user.provider.concrete.default',
126131
'with_user_checker',
127132
'security.authentication.basic_entry_point.with_user_checker',
133+
null,
134+
null,
128135
array(
129136
'http_basic',
130137
'anonymous',

‎src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public function testGetters()
3232

3333
$config = new FirewallConfig(
3434
'foo_firewall',
35-
$options['request_matcher'],
3635
$options['user_checker'],
36+
$options['request_matcher'],
3737
$options['security'],
3838
$options['stateless'],
3939
$options['provider'],

‎src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FirewallContextTest extends \PHPUnit_Framework_TestCase
2020
{
2121
public function testGetters()
2222
{
23-
$config = new FirewallConfig('main', 'request_matcher', 'user_checker');
23+
$config = new FirewallConfig('main', 'user_checker', 'request_matcher');
2424

2525
$exceptionListener = $this
2626
->getMockBuilder(ExceptionListener::class)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.