1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kaliop\IdentityManagementBundle\Security\Factory; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory; |
6
|
|
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; |
7
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
9
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator; |
10
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @see http://www.caillarec-coste.fr/symfony2-introduire-une-logique-personnalise-durant-le-login/ |
14
|
|
|
*/ |
15
|
|
|
class RemoteUserFactory extends FormLoginFactory //implements SecurityFactoryInterface |
16
|
|
|
{ |
17
|
|
|
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) |
18
|
|
|
{ |
19
|
|
|
$providerId = 'security.authentication.provider.remoteuser.'.$id; |
20
|
|
|
$container |
21
|
|
|
->setDefinition($providerId, new DefinitionDecorator('kaliop_identity.security.authentication.provider.remoteuser')) |
22
|
|
|
->replaceArgument(0, new Reference($config['client'])) |
23
|
|
|
->replaceArgument(1, new Reference($userProvider)) |
24
|
|
|
->replaceArgument(2, $id) |
25
|
|
|
; |
26
|
|
|
|
27
|
|
|
//$listenerId = 'security.authentication.listener.ams.'.$id; |
|
|
|
|
28
|
|
|
//$container->setDefinition($listenerId, new DefinitionDecorator('kaliop_identity.security.authentication.listener.remoteuser')); |
|
|
|
|
29
|
|
|
$listenerId = $this->createListener($container, $id, $config, $userProvider); |
30
|
|
|
|
31
|
|
|
return array($providerId, $listenerId, $defaultEntryPoint); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function getListenerId() |
35
|
|
|
{ |
36
|
|
|
return 'kaliop_identity.security.authentication.listener.remoteuser'; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Defines the position at which the provider is called. |
41
|
|
|
* Possible values: pre_auth, form, http, and remember_me. |
42
|
|
|
* |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
public function getPosition() |
46
|
|
|
{ |
47
|
|
|
return 'form'; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getKey() |
51
|
|
|
{ |
52
|
|
|
return 'remoteuser_login'; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function addConfiguration(NodeDefinition $node) |
56
|
|
|
{ |
57
|
|
|
$node |
58
|
|
|
->children() |
59
|
|
|
->scalarNode('client') |
60
|
|
|
->end(); |
61
|
|
|
} |
62
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.