zend-blog-3-backend

Форк
0
65 строк · 1.9 Кб
1
<?php
2

3
namespace App\DependencyInjection\Security\Factory;
4

5
use App\Security\Authentication\Provider\WsseAuthenticationProvider;
6
use App\Security\Firewall\WsseAuthenticationListener;
7
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
8
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
9
use Symfony\Component\DependencyInjection\ChildDefinition;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\Reference;
12

13
class WsseFactory implements SecurityFactoryInterface
14
{
15
    /**
16
     * @param ContainerBuilder $container
17
     * @param $id
18
     * @param $config
19
     * @param $userProvider
20
     * @param $defaultEntryPoint
21
     *
22
     * @return array
23
     */
24
    public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
25
    {
26
        $providerId = 'security.authentication.provider.wsse.' . $id;
27
        $container
28
            ->setDefinition($providerId, new ChildDefinition(WsseAuthenticationProvider::class))
29
            ->setArgument(0, new Reference($userProvider))
30
            ->setArgument(1, $config['lifetime'])
31
        ;
32

33
        $listenerId = 'security.authentication.listener.wsse.' . $id;
34
        $container->setDefinition($listenerId, new ChildDefinition(WsseAuthenticationListener::class));
35

36
        return [$providerId, $listenerId, $defaultEntryPoint];
37
    }
38

39
    /**
40
     * @return string
41
     */
42
    public function getPosition()
43
    {
44
        return 'pre_auth';
45
    }
46

47
    /**
48
     * @return string
49
     */
50
    public function getKey()
51
    {
52
        return 'wsse';
53
    }
54

55
    /**
56
     * @param NodeDefinition $builder
57
     */
58
    public function addConfiguration(NodeDefinition $builder)
59
    {
60
        $builder
61
            ->children()
62
                ->scalarNode('lifetime')->defaultValue(300)->end()
63
            ->end();
64
    }
65
}
66

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.