Skip to content

Commit

Permalink
[Security] fix DI for SimpleFormAuthenticationListener
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Jan 21, 2014
1 parent 783a45d commit b3f5fa9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Expand Up @@ -75,12 +75,10 @@ protected function createListener($container, $id, $config, $userProvider)
{
$listenerId = parent::createListener($container, $id, $config, $userProvider);

if (isset($config['csrf_provider'])) {
$container
->getDefinition($listenerId)
->addArgument(new Reference($config['csrf_provider']))
;
}
$container
->getDefinition($listenerId)
->addArgument(isset($config['csrf_provider']) ? new Reference($config['csrf_provider']) : null)
;

return $listenerId;
}
Expand Down
Expand Up @@ -63,18 +63,14 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
protected function createListener($container, $id, $config, $userProvider)
{
$listenerId = parent::createListener($container, $id, $config, $userProvider);
$listener = $container->getDefinition($listenerId);

if (!isset($config['csrf_token_generator'])) {
$listener->addArgument(null);
}

$simpleAuthHandlerId = 'security.authentication.simple_success_failure_handler.'.$id;
$simpleAuthHandler = $container->setDefinition($simpleAuthHandlerId, new DefinitionDecorator('security.authentication.simple_success_failure_handler'));
$simpleAuthHandler->replaceArgument(0, new Reference($config['authenticator']));
$simpleAuthHandler->replaceArgument(1, new Reference($this->getSuccessHandlerId($id)));
$simpleAuthHandler->replaceArgument(2, new Reference($this->getFailureHandlerId($id)));

$listener = $container->getDefinition($listenerId);
$listener->replaceArgument(5, new Reference($simpleAuthHandlerId));
$listener->replaceArgument(6, new Reference($simpleAuthHandlerId));
$listener->addArgument(new Reference($config['authenticator']));
Expand Down

0 comments on commit b3f5fa9

Please sign in to comment.