|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Nuvola\OAuth2AuthenticatorBundle\DependencyInjection; |
| 6 | + |
| 7 | +use Symfony\Component\Config\FileLocator; |
| 8 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 9 | +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
| 10 | +use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; |
| 11 | +use Nuvola\OAuth2AuthenticatorBundle\Repository\UserRepository; |
| 12 | +use Nuvola\OAuth2AuthenticatorBundle\Service\IntrospectService; |
| 13 | +use Nuvola\OAuth2AuthenticatorBundle\Token\TokenFactory; |
| 14 | + |
| 15 | +final class OAuth2AuthenticatorExtension extends ConfigurableExtension |
| 16 | +{ |
| 17 | + public function loadInternal(array $mergedConfig, ContainerBuilder $container): void |
| 18 | + { |
| 19 | + $loader = new YamlFileLoader( |
| 20 | + $container, |
| 21 | + new FileLocator(__DIR__.'/../Resources/config') |
| 22 | + ); |
| 23 | + |
| 24 | + $loader->load('services.yaml'); |
| 25 | + |
| 26 | + $definition = $container->getDefinition(IntrospectService::class); |
| 27 | + $definition->replaceArgument(1, $mergedConfig['client_id']); |
| 28 | + $definition->replaceArgument(2, $mergedConfig['client_secret']); |
| 29 | + $definition->replaceArgument(3, $mergedConfig['itrospect']['endpoint']); |
| 30 | + |
| 31 | + $definition = $container->getDefinition(TokenFactory::class); |
| 32 | + $definition->replaceArgument(0, $mergedConfig['itrospect']['user_identifier_property']); |
| 33 | + |
| 34 | + $definition = $container->getDefinition(UserRepository::class); |
| 35 | + $definition->replaceArgument(1, $mergedConfig['userinfo_endpoint'] ?? ''); |
| 36 | + } |
| 37 | + |
| 38 | + public function getAlias(): string |
| 39 | + { |
| 40 | + return 'oauth2_authenticator'; |
| 41 | + } |
| 42 | +} |
0 commit comments