vendor\symfony\security-bundle\SecurityBundle.php line 52

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