vendor/lexik/jwt-authentication-bundle/LexikJWTAuthenticationBundle.php line 22

Open in your IDE?
  1. <?php
  2. namespace Lexik\Bundle\JWTAuthenticationBundle;
  3. use Lexik\Bundle\JWTAuthenticationBundle\DependencyInjection\Compiler\DeprecateLegacyGuardAuthenticatorPass;
  4. use Lexik\Bundle\JWTAuthenticationBundle\DependencyInjection\Compiler\RegisterLegacyGuardAuthenticatorPass;
  5. use Lexik\Bundle\JWTAuthenticationBundle\DependencyInjection\Compiler\WireGenerateTokenCommandPass;
  6. use Lexik\Bundle\JWTAuthenticationBundle\DependencyInjection\Security\Factory\JWTAuthenticatorFactory;
  7. use Lexik\Bundle\JWTAuthenticationBundle\DependencyInjection\Security\Factory\JWTFactory;
  8. use Lexik\Bundle\JWTAuthenticationBundle\DependencyInjection\Security\Factory\JWTUserFactory;
  9. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
  10. use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
  11. use Symfony\Component\Console\Application;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\HttpKernel\Bundle\Bundle;
  14. /**
  15.  * LexikJWTAuthenticationBundle.
  16.  *
  17.  * @author Nicolas Cabot <n.cabot@lexik.fr>
  18.  */
  19. class LexikJWTAuthenticationBundle extends Bundle
  20. {
  21.     /**
  22.      * {@inheritdoc}
  23.      */
  24.     public function build(ContainerBuilder $container)
  25.     {
  26.         parent::build($container);
  27.         $container->addCompilerPass(new WireGenerateTokenCommandPass());
  28.         $container->addCompilerPass(new DeprecateLegacyGuardAuthenticatorPass());
  29.         /** @var SecurityExtension $extension */
  30.         $extension $container->getExtension('security');
  31.         $extension->addUserProviderFactory(new JWTUserFactory());
  32.         $extension->addSecurityListenerFactory(new JWTFactory(false)); // BC 1.x, to be removed in 3.0
  33.         if (interface_exists(AuthenticatorFactoryInterface::class)) {
  34.             $extension->addSecurityListenerFactory(new JWTAuthenticatorFactory());
  35.         }
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function registerCommands(Application $application)
  41.     {
  42.         // noop
  43.     }
  44. }