Failed Conditions
Push — master ( 349866...67c1d1 )
by Florent
10:56 queued 06:08
created

OAuth2SecurityFactory::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\SecurityBundle\Security\Factory;
15
16
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
17
use Symfony\Component\DependencyInjection\ChildDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Reference;
20
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
21
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
22
23
final class OAuth2SecurityFactory implements SecurityFactoryInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
29
    {
30
        $providerId = 'security.authentication.provider.oauth2.'.$id;
31
        $container
32
            ->setDefinition($providerId, new ChildDefinition('oauth2_security.provider'))
33
            ->setAutowired(true)
34
        ;
35
36
        $listenerId = 'security.authentication.listener.oauth2.'.$id;
37
        $container
38
            ->setDefinition($listenerId, new ChildDefinition('oauth2_security.listener'))
39
            ->setArguments([
40
                new Reference(TokenStorageInterface::class),
41
                new Reference('security.authentication.manager'),
42
                new Reference('oauth2_security.token_type_manager'),
43
                new Reference('oauth2_security.access_token_handler_manager'),
44
            ])
45
        ;
46
47
        return [$providerId, $listenerId, 'oauth2_security.entry_point'];
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getPosition()
54
    {
55
        return 'pre_auth';
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function getKey()
62
    {
63
        return 'oauth2';
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function addConfiguration(NodeDefinition $node)
70
    {
71
    }
72
}
73