vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php line 50

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\SecurityBundle;
  11. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
  12. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
  13. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSessionDomainConstraintPass;
  14. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterCsrfTokenClearingLogoutHandlerPass;
  15. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterTokenUsageTrackingPass;
  16. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AnonymousFactory;
  17. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory;
  18. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginLdapFactory;
  19. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
  20. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicFactory;
  21. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicLdapFactory;
  22. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginFactory;
  23. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginLdapFactory;
  24. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory;
  25. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RemoteUserFactory;
  26. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleFormFactory;
  27. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimplePreAuthenticationFactory;
  28. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\X509Factory;
  29. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\InMemoryFactory;
  30. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\LdapFactory;
  31. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  32. use Symfony\Component\DependencyInjection\ContainerBuilder;
  33. use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
  34. use Symfony\Component\HttpKernel\Bundle\Bundle;
  35. use Symfony\Component\Security\Core\AuthenticationEvents;
  36. use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
  37. use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
  38. use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
  39. use Symfony\Component\Security\Http\Event\SwitchUserEvent;
  40. use Symfony\Component\Security\Http\SecurityEvents;
  41. /**
  42.  * Bundle.
  43.  *
  44.  * @author Fabien Potencier <fabien@symfony.com>
  45.  */
  46. class SecurityBundle extends Bundle
  47. {
  48.     public function build(ContainerBuilder $container)
  49.     {
  50.         parent::build($container);
  51.         $extension $container->getExtension('security');
  52.         $extension->addSecurityListenerFactory(new FormLoginFactory());
  53.         $extension->addSecurityListenerFactory(new FormLoginLdapFactory());
  54.         $extension->addSecurityListenerFactory(new JsonLoginFactory());
  55.         $extension->addSecurityListenerFactory(new JsonLoginLdapFactory());
  56.         $extension->addSecurityListenerFactory(new HttpBasicFactory());
  57.         $extension->addSecurityListenerFactory(new HttpBasicLdapFactory());
  58.         $extension->addSecurityListenerFactory(new RememberMeFactory());
  59.         $extension->addSecurityListenerFactory(new X509Factory());
  60.         $extension->addSecurityListenerFactory(new RemoteUserFactory());
  61.         $extension->addSecurityListenerFactory(new SimplePreAuthenticationFactory(false));
  62.         $extension->addSecurityListenerFactory(new SimpleFormFactory(false));
  63.         $extension->addSecurityListenerFactory(new GuardAuthenticationFactory());
  64.         $extension->addSecurityListenerFactory(new AnonymousFactory());
  65.         $extension->addUserProviderFactory(new InMemoryFactory());
  66.         $extension->addUserProviderFactory(new LdapFactory());
  67.         $container->addCompilerPass(new AddExpressionLanguageProvidersPass());
  68.         $container->addCompilerPass(new AddSecurityVotersPass());
  69.         $container->addCompilerPass(new AddSessionDomainConstraintPass(), PassConfig::TYPE_BEFORE_REMOVING);
  70.         $container->addCompilerPass(new RegisterCsrfTokenClearingLogoutHandlerPass());
  71.         $container->addCompilerPass(new RegisterTokenUsageTrackingPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION200);
  72.         $container->addCompilerPass(new AddEventAliasesPass([
  73.             AuthenticationSuccessEvent::class => AuthenticationEvents::AUTHENTICATION_SUCCESS,
  74.             AuthenticationFailureEvent::class => AuthenticationEvents::AUTHENTICATION_FAILURE,
  75.             InteractiveLoginEvent::class => SecurityEvents::INTERACTIVE_LOGIN,
  76.             SwitchUserEvent::class => SecurityEvents::SWITCH_USER,
  77.         ]));
  78.     }
  79. }