vendor/symfony/security-bundle/SecurityBundle.php line 51

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\RegisterCsrfFeaturesPass;
  15. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterEntryPointPass;
  16. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterGlobalSecurityEventListenersPass;
  17. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterLdapLocatorPass;
  18. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterTokenUsageTrackingPass;
  19. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\SortFirewallListenersPass;
  20. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AnonymousFactory;
  21. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\CustomAuthenticatorFactory;
  22. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory;
  23. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginLdapFactory;
  24. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
  25. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicFactory;
  26. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicLdapFactory;
  27. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginFactory;
  28. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginLdapFactory;
  29. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\LoginLinkFactory;
  30. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\LoginThrottlingFactory;
  31. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory;
  32. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RemoteUserFactory;
  33. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\X509Factory;
  34. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\InMemoryFactory;
  35. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\LdapFactory;
  36. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  37. use Symfony\Component\DependencyInjection\ContainerBuilder;
  38. use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
  39. use Symfony\Component\HttpKernel\Bundle\Bundle;
  40. use Symfony\Component\Security\Core\AuthenticationEvents;
  41. use Symfony\Component\Security\Http\SecurityEvents;
  42. /**
  43.  * Bundle.
  44.  *
  45.  * @author Fabien Potencier <fabien@symfony.com>
  46.  */
  47. class SecurityBundle extends Bundle
  48. {
  49.     public function build(ContainerBuilder $container)
  50.     {
  51.         parent::build($container);
  52.         $extension $container->getExtension('security');
  53.         $extension->addSecurityListenerFactory(new FormLoginFactory());
  54.         $extension->addSecurityListenerFactory(new FormLoginLdapFactory());
  55.         $extension->addSecurityListenerFactory(new JsonLoginFactory());
  56.         $extension->addSecurityListenerFactory(new JsonLoginLdapFactory());
  57.         $extension->addSecurityListenerFactory(new HttpBasicFactory());
  58.         $extension->addSecurityListenerFactory(new HttpBasicLdapFactory());
  59.         $extension->addSecurityListenerFactory(new RememberMeFactory());
  60.         $extension->addSecurityListenerFactory(new X509Factory());
  61.         $extension->addSecurityListenerFactory(new RemoteUserFactory());
  62.         $extension->addSecurityListenerFactory(new GuardAuthenticationFactory());
  63.         $extension->addSecurityListenerFactory(new AnonymousFactory());
  64.         $extension->addSecurityListenerFactory(new CustomAuthenticatorFactory());
  65.         $extension->addSecurityListenerFactory(new LoginThrottlingFactory());
  66.         $extension->addSecurityListenerFactory(new LoginLinkFactory());
  67.         $extension->addUserProviderFactory(new InMemoryFactory());
  68.         $extension->addUserProviderFactory(new LdapFactory());
  69.         $container->addCompilerPass(new AddExpressionLanguageProvidersPass());
  70.         $container->addCompilerPass(new AddSecurityVotersPass());
  71.         $container->addCompilerPass(new AddSessionDomainConstraintPass(), PassConfig::TYPE_BEFORE_REMOVING);
  72.         $container->addCompilerPass(new RegisterCsrfFeaturesPass());
  73.         $container->addCompilerPass(new RegisterTokenUsageTrackingPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION200);
  74.         $container->addCompilerPass(new RegisterLdapLocatorPass());
  75.         $container->addCompilerPass(new RegisterEntryPointPass(), PassConfig::TYPE_BEFORE_REMOVING);
  76.         // must be registered after RegisterListenersPass (in the FrameworkBundle)
  77.         $container->addCompilerPass(new RegisterGlobalSecurityEventListenersPass(), PassConfig::TYPE_BEFORE_REMOVING, -200);
  78.         // execute after ResolveChildDefinitionsPass optimization pass, to ensure class names are set
  79.         $container->addCompilerPass(new SortFirewallListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
  80.         $container->addCompilerPass(new AddEventAliasesPass(array_merge(
  81.             AuthenticationEvents::ALIASES,
  82.             SecurityEvents::ALIASES
  83.         )));
  84.     }
  85. }