Commit 1fcdbef8 authored by Fabien Potencier's avatar Fabien Potencier

made the form authentication listener reusable when creating a custom authentication listener

parent 1e2218f9
...@@ -33,7 +33,6 @@ use Symfony\Component\Security\Core\Role\RoleHierarchy; ...@@ -33,7 +33,6 @@ use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Symfony\Component\Security\Http\Firewall; use Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Http\FirewallMap; use Symfony\Component\Security\Http\FirewallMap;
use Symfony\Component\Security\Http\Firewall\AccessListener; use Symfony\Component\Security\Http\Firewall\AccessListener;
use Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener;
use Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener; use Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener;
use Symfony\Component\Security\Http\Firewall\LogoutListener; use Symfony\Component\Security\Http\Firewall\LogoutListener;
use Symfony\Component\Security\Http\Firewall\SwitchUserListener; use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
...@@ -331,19 +330,23 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -331,19 +330,23 @@ class SecurityServiceProvider implements ServiceProviderInterface
}); });
}); });
$app['security.authentication_listener.form._proto'] = $app->protect(function ($providerKey, $options) use ($app, $that) { $app['security.authentication_listener.form._proto'] = $app->protect(function ($name, $options, $class = null) use ($app, $that) {
return $app->share(function () use ($app, $providerKey, $options, $that) { return $app->share(function () use ($app, $name, $options, $that, $class) {
$that->addFakeRoute(array('post', $tmp = isset($options['check_path']) ? $options['check_path'] : '/login_check', str_replace('/', '_', ltrim($tmp, '/')))); $that->addFakeRoute(array('match', $tmp = isset($options['check_path']) ? $options['check_path'] : '/login_check', str_replace('/', '_', ltrim($tmp, '/'))));
if (null === $class) {
$class = 'Symfony\\Component\\Security\\Http\\Firewall\\UsernamePasswordFormAuthenticationListener';
}
return new UsernamePasswordFormAuthenticationListener( return new $class(
$app['security'], $app['security'],
$app['security.authentication_manager'], $app['security.authentication_manager'],
$app['security.session_strategy'], isset($app['security.session_strategy.'.$name]) ? $app['security.session_strategy.'.$name] : $app['security.session_strategy'],
$app['security.http_utils'], $app['security.http_utils'],
$providerKey, $name,
$options, $options,
null, // AuthenticationSuccessHandlerInterface isset($app['security.authentication.success_handler.'.$name]) ? $app['security.authentication.success_handler.'.$name] : null,
null, // AuthenticationFailureHandlerInterface isset($app['security.authentication.failure_handler.'.$name]) ? $app['security.authentication.failure_handler.'.$name] : null,
$app['logger'], $app['logger'],
$app['dispatcher'], $app['dispatcher'],
isset($options['with_csrf']) && $options['with_csrf'] && isset($app['form.csrf_provider']) ? $app['form.csrf_provider'] : null isset($options['with_csrf']) && $options['with_csrf'] && isset($app['form.csrf_provider']) ? $app['form.csrf_provider'] : null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment