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

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