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

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