zend-blog-3-backend
65 строк · 1.9 Кб
1<?php
2
3namespace App\DependencyInjection\Security\Factory;
4
5use App\Security\Authentication\Provider\WsseAuthenticationProvider;
6use App\Security\Firewall\WsseAuthenticationListener;
7use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
8use Symfony\Component\Config\Definition\Builder\NodeDefinition;
9use Symfony\Component\DependencyInjection\ChildDefinition;
10use Symfony\Component\DependencyInjection\ContainerBuilder;
11use Symfony\Component\DependencyInjection\Reference;
12
13class 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*/
24public 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
36return [$providerId, $listenerId, $defaultEntryPoint];
37}
38
39/**
40* @return string
41*/
42public function getPosition()
43{
44return 'pre_auth';
45}
46
47/**
48* @return string
49*/
50public function getKey()
51{
52return 'wsse';
53}
54
55/**
56* @param NodeDefinition $builder
57*/
58public function addConfiguration(NodeDefinition $builder)
59{
60$builder
61->children()
62->scalarNode('lifetime')->defaultValue(300)->end()
63->end();
64}
65}
66