Passed
Push — master ( a6a317...11687d )
by Pol
11:16
created

ApiGwAuthenticationExtension::prepend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 22
ccs 0
cts 1
cp 0
rs 9.9332
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcPhp\ApiGwAuthenticationBundle\DependencyInjection;
6
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
10
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
13
class ApiGwAuthenticationExtension extends Extension implements PrependExtensionInterface
14
{
15
    public function load(array $configs, ContainerBuilder $container): void
16
    {
17
        $configuration = new Configuration();
18
        $config = $this->processConfiguration($configuration, $configs);
19
20
        // Load API GW Authentication configuration.
21
        $container->setParameter('api_gw_authentication', $config);
22
23
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
24
        $loader->load('services.php');
25
    }
26
27
    public function prepend(ContainerBuilder $container)
28
    {
29
        // Configure the symfony/security bundle
30
        // Add the API Gateway user provider.
31
        $container
32
            ->loadFromExtension(
33
                'security',
34
                [
35
                    'providers' => [
36
                        'api_gw_authentication' => [
37
                            'id' => 'api_gw_authentication.user_provider',
38
                        ],
39
                    ],
40
                ]
41
            );
42
43
        // Configure the lexik/jwt-authenication bundle
44
        $container
45
            ->loadFromExtension(
46
                'lexik_jwt_authentication',
47
                [
48
                    'user_identity_field' => 'sub',
49
                ]
50
            );
51
    }
52
}
53