vendor/hwi/oauth-bundle/DependencyInjection/Security/Factory/OAuthAuthenticatorFactory.php line 22

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the HWIOAuthBundle package.
  4.  *
  5.  * (c) Hardware Info <opensource@hardware.info>
  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 HWI\Bundle\OAuthBundle\DependencyInjection\Security\Factory;
  11. use HWI\Bundle\OAuthBundle\Security\Http\Authenticator\OAuthAuthenticator;
  12. use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\DependencyInjection\Reference;
  15. /**
  16.  * @author Vadim Borodavko <vadim.borodavko@gmail.com>
  17.  */
  18. final class OAuthAuthenticatorFactory extends OAuthFactory implements AuthenticatorFactoryInterface
  19. {
  20.     /**
  21.      * {@inheritdoc}
  22.      */
  23.     public function createAuthenticator(
  24.         ContainerBuilder $container,
  25.         string $firewallName,
  26.         array $config,
  27.         string $userProviderId
  28.     ): string {
  29.         $authenticatorId 'security.authenticator.oauth.'.$firewallName;
  30.         $this->createResourceOwnerMap($container$firewallName$config);
  31.         $container
  32.             ->register($authenticatorIdOAuthAuthenticator::class)
  33.             ->addArgument(new Reference('security.http_utils'))
  34.             ->addArgument(
  35.                 $this->createOAuthAwareUserProvider($container$firewallName$config['oauth_user_provider'])
  36.             )
  37.             ->addArgument($this->getResourceOwnerMapReference($firewallName))
  38.             ->addArgument($config['resource_owners'])
  39.             ->addArgument(new Reference($this->createAuthenticationSuccessHandler($container$firewallName$config)))
  40.             ->addArgument(new Reference($this->createAuthenticationFailureHandler($container$firewallName$config)))
  41.         ;
  42.         return $authenticatorId;
  43.     }
  44. }