SecurityBundle.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\AddSecurityVotersPass;
  12. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSessionDomainConstraintPass;
  13. use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\RegisterCsrfTokenClearingLogoutHandlerPass;
  14. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory;
  15. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginLdapFactory;
  16. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
  17. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicFactory;
  18. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasicLdapFactory;
  19. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpDigestFactory;
  20. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory;
  21. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RemoteUserFactory;
  22. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleFormFactory;
  23. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimplePreAuthenticationFactory;
  24. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\X509Factory;
  25. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\InMemoryFactory;
  26. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\LdapFactory;
  27. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  28. use Symfony\Component\DependencyInjection\ContainerBuilder;
  29. use Symfony\Component\HttpKernel\Bundle\Bundle;
  30. /**
  31. * Bundle.
  32. *
  33. * @author Fabien Potencier <fabien@symfony.com>
  34. */
  35. class SecurityBundle extends Bundle
  36. {
  37. public function build(ContainerBuilder $container)
  38. {
  39. parent::build($container);
  40. $extension = $container->getExtension('security');
  41. $extension->addSecurityListenerFactory(new FormLoginFactory());
  42. $extension->addSecurityListenerFactory(new FormLoginLdapFactory());
  43. $extension->addSecurityListenerFactory(new HttpBasicFactory());
  44. $extension->addSecurityListenerFactory(new HttpBasicLdapFactory());
  45. $extension->addSecurityListenerFactory(new HttpDigestFactory());
  46. $extension->addSecurityListenerFactory(new RememberMeFactory());
  47. $extension->addSecurityListenerFactory(new X509Factory());
  48. $extension->addSecurityListenerFactory(new RemoteUserFactory());
  49. $extension->addSecurityListenerFactory(new SimplePreAuthenticationFactory());
  50. $extension->addSecurityListenerFactory(new SimpleFormFactory());
  51. $extension->addSecurityListenerFactory(new GuardAuthenticationFactory());
  52. $extension->addUserProviderFactory(new InMemoryFactory());
  53. $extension->addUserProviderFactory(new LdapFactory());
  54. $container->addCompilerPass(new AddSecurityVotersPass());
  55. $container->addCompilerPass(new AddSessionDomainConstraintPass(), PassConfig::TYPE_BEFORE_REMOVING);
  56. $container->addCompilerPass(new RegisterCsrfTokenClearingLogoutHandlerPass());
  57. }
  58. }