guard.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\Component\DependencyInjection\Loader\Configurator;
  11. use Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener;
  12. use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
  13. use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
  14. return static function (ContainerConfigurator $container) {
  15. $container->services()
  16. ->set('security.authentication.guard_handler', GuardAuthenticatorHandler::class)
  17. ->args([
  18. service('security.token_storage'),
  19. service('event_dispatcher')->nullOnInvalid(),
  20. abstract_arg('stateless firewall keys'),
  21. ])
  22. ->call('setSessionAuthenticationStrategy', [service('security.authentication.session_strategy')])
  23. ->alias(GuardAuthenticatorHandler::class, 'security.authentication.guard_handler')
  24. ->set('security.authentication.provider.guard', GuardAuthenticationProvider::class)
  25. ->abstract()
  26. ->args([
  27. abstract_arg('Authenticators'),
  28. abstract_arg('User Provider'),
  29. abstract_arg('Provider-shared Key'),
  30. abstract_arg('User Checker'),
  31. service('security.password_encoder'),
  32. ])
  33. ->set('security.authentication.listener.guard', GuardAuthenticationListener::class)
  34. ->abstract()
  35. ->args([
  36. service('security.authentication.guard_handler'),
  37. service('security.authentication.manager'),
  38. abstract_arg('Provider-shared Key'),
  39. abstract_arg('Authenticators'),
  40. service('logger')->nullOnInvalid(),
  41. ])
  42. ->tag('monolog.logger', ['channel' => 'security'])
  43. ;
  44. };