Passed
Pull Request — master (#56)
by Mark
01:55
created

HmacFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 5
dl 0
loc 9
ccs 0
cts 6
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Acquia\Hmac\Symfony;
4
5
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
6
use Symfony\Component\DependencyInjection\ChildDefinition;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
9
10
/**
11
 * Class HmacFactory
12
 *
13
 * Provides implementation of authentication provider and listener for Symfony.
14
 */
15
class HmacFactory implements SecurityFactoryInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
21
    {
22
        $providerId = 'security.authentication.provider.hmac.' . $id;
23
        $container->setDefinition($providerId, new ChildDefinition('hmac.security.authentication.provider'));
24
25
        $listenerId = 'security.authentication.listener.hmac.' . $id;
26
        $container->setDefinition($listenerId, new ChildDefinition('hmac.security.authentication.listener'));
27
28
        return [$providerId, $listenerId, $defaultEntryPoint];
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getPosition()
35
    {
36
        return 'pre_auth';
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getKey()
43
    {
44
        return 'hmac_auth';
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function addConfiguration(NodeDefinition $node)
51
    {
52
    }
53
}
54