ApiGwAuthenticationExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 16
dl 0
loc 36
ccs 0
cts 11
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 10 1
A prepend() 0 22 1
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @see https://github.com/ecphp
8
 */
9
10
declare(strict_types=1);
11
12
namespace EcPhp\ApiGwAuthenticationBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
17
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
18
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
19
20
class ApiGwAuthenticationExtension extends Extension implements PrependExtensionInterface
21
{
22
    public function load(array $configs, ContainerBuilder $container): void
23
    {
24
        $configuration = new Configuration();
25
        $config = $this->processConfiguration($configuration, $configs);
26
27
        // Load API GW Authentication configuration.
28
        $container->setParameter('api_gw_authentication', $config);
29
30
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
31
        $loader->load('services.php');
32
    }
33
34
    public function prepend(ContainerBuilder $container)
35
    {
36
        // Configure the symfony/security bundle
37
        // Add the API Gateway user provider.
38
        $container
39
            ->loadFromExtension(
40
                'security',
41
                [
42
                    'providers' => [
43
                        'api_gw_authentication' => [
44
                            'id' => 'api_gw_authentication.user_provider',
45
                        ],
46
                    ],
47
                ]
48
            );
49
50
        // Configure the lexik/jwt-authenication bundle
51
        $container
52
            ->loadFromExtension(
53
                'lexik_jwt_authentication',
54
                [
55
                    'user_identity_field' => 'sub',
56
                ]
57
            );
58
    }
59
}
60