8000 [SecurityBundle] FirewallConfig's user_checker should be mandatory by chalasr · Pull Request #20407 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[SecurityBundle] FirewallConfig's user_checker should be mandatory #20407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,15 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
}

$config->replaceArgument(1, (string) $matcher);
$config->replaceArgument(2, $firewall['security']);
$config->replaceArgument(2, $firewall['user_checker']);
$config->replaceArgument(3, $firewall['security']);

// Security disabled?
if (false === $firewall['security']) {
return array($matcher, array(), null);
}

$config->replaceArgument(3, $firewall['stateless']);
$config->replaceArgument(4, $firewall['stateless']);

// Provider id (take the first registered provider if none defined)
if (isset($firewall['provider'])) {
Expand All @@ -296,7 +297,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$defaultProvider = reset($providerIds);
}

$config->replaceArgument(4, $defaultProvider);
$config->replaceArgument(5, $defaultProvider);

// Register listeners
$listeners = array();
Expand All @@ -312,7 +313,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$contextKey = $firewall['context'];
}

$config->replaceArgument(5, $contextKey);
$config->replaceArgument(6, $contextKey);

$listeners[] = new Reference($this->createContextListener($container, $contextKey));
}
Expand Down Expand Up @@ -382,7 +383,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
// Authentication listeners
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $configuredEntryPoint);

$config->replaceArgument(6, $configuredEntryPoint ?: $defaultEntryPoint);
$config->replaceArgument(7, $configuredEntryPoint ?: $defaultEntryPoint);

$listeners = array_merge($listeners, $authListeners);

Expand All @@ -399,14 +400,13 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless']));

if (isset($firewall['access_denied_handler'])) {
$config->replaceArgument(7, $firewall['access_denied_handler']);
$config->replaceArgument(8, $firewall['access_denied_handler']);
}
if (isset($firewall['access_denied_url'])) {
$config->replaceArgument(8, $firewall['access_denied_url']);
$config->replaceArgument(9, $firewall['access_denied_url']);
}

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

foreach ($this->factories as $position) {
foreach ($position as $factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@
<service id="security.firewall.config" class="Symfony\Bundle\SecurityBundle\Security\FirewallConfig" abstract="true" public="false">
<argument /> <!-- name -->
<argument /> <!-- request_matcher -->
<argument /> <!-- user_checker -->
<argument /> <!-- security enabled -->
<argument /> <!-- stateless -->
<argument /> <!-- provider -->
<argument /> <!-- context -->
<argument /> <!-- entry_point -->
<argument /> <!-- access_denied_handler -->
<argument /> <!-- access_denied_url -->
<argument /> <!-- user_checker -->
<argument type="collection" /> <!-- listeners -->
</service>

Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Bundle/SecurityBundle/Security/FirewallConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@ final class FirewallConfig
{
private $name;
private $requestMatcher;
private $userChecker;
private $securityEnabled;
private $stateless;
private $provider;
private $context;
private $entryPoint;
private $accessDeniedHandler;
private $accessDeniedUrl;
private $userChecker;
private $listeners;

/**
* @param string $name
* @param string $requestMatcher
* @param string $userChecker
* @param bool $securityEnabled
* @param bool $stateless
* @param string|null $provider
* @param string|null $context
* @param string|null $entryPoint
* @param string|null $accessDeniedHandler
* @param string|null $accessDeniedUrl
* @param string|null $userChecker
* @param string[] $listeners
*/
public function __construct($name, $requestMatcher, $securityEnabled = true, $stateless = false, $provider = null, $context = null, $entryPoint = null, $accessDeniedHandler = null, $accessDeniedUrl = null, $userChecker = null, $listeners = array())
public function __construct($name, $requestMatcher, $userChecker, $securityEnabled = true, $stateless = false, $provider = null, $context = null, $entryPoint = null, $accessDeniedHandler = null, $accessDeniedUrl = null, $listeners = array())
{
$this->name = $name;
$this->requestMatcher = $requestMatcher;
$this->userChecker = $userChecker;
$this->securityEnabled = $securityEnabled;
$this->stateless = $stateless;
$this->provider = $provider;
$this->context = $context;
$this->entryPoint = $entryPoint;
$this->accessDeniedHandler = $accessDeniedHandler;
$this->accessDeniedUrl = $accessDeniedUrl;
$this->userChecker = $userChecker;
$this->listeners = $listeners;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be reverted

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expand Down
6D40
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testCollectAuthenticationTokenAndRoles(array $roles, array $norm

public function testGetFirewall()
{
$firewallConfig = new FirewallConfig('dummy', 'security.request_matcher.dummy');
$firewallConfig = new FirewallConfig('dummy', 'security.request_matcher.dummy', 'security.user_checker.dummy');
$request = $this->getRequest();

$firewallMap = $this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,17 @@ public function testFirewalls()
array(
'simple',
'security.request_matcher.707b20193d4cb9f2718114abcbebb32af48f948484fc166a03482f49bf14f25e271f72c7',
9E88 'security.user_checker',
false,
),
array(
'secure',
'',
'security.user_checker',
true,
true,
'security.user.provider.concrete.default',
'security.authentication.form_entry_point.secure',
'security.user_checker',
array(
'logout',
'switch_user',
Expand All @@ -104,12 +105,12 @@ public function testFirewalls()
array(
'host',
'security.request_matcher.dda8b565689ad8509623ee68fb2c639cd81cd4cb339d60edbaf7d67d30e6aa09bd8c63c3',
'security.user_checker',
true,
false,
'security.user.provider.concrete.default',
'host',
'security.authentication.basic_entry_point.host',
'security.user_checker',
array(
'http_basic',
'anonymous',
Expand All @@ -118,12 +119,12 @@ public function testFirewalls()
array(
'with_user_checker',
'',
'app.user_checker',
true,
false,
'security.user.provider.concrete.default',
'with_user_checker',
'security.authentication.basic_entry_point.with_user_checker',
'app.user_checker',
array(
'http_basic',
'anonymous',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public function testGetters()
$config = new FirewallConfig(
'foo_firewall',
$options['request_matcher'],
$options['user_checker'],
$options['security'],
$options['stateless'],
$options['provider'],
$options['context'],
$options['entry_point'],
$options['access_denied_handler'],
$options['access_denied_url'],
$options['user_checker'],
$listeners
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FirewallContextTest extends \PHPUnit_Framework_TestCase
{
public function testGetters()
{
$config = new FirewallConfig('main', 'request_matcher');
$config = new FirewallConfig('main', 'request_matcher', 'user_checker');

$exceptionListener = $this
->getMockBuilder(ExceptionListener::class)
Expand Down
0