1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rezzza\SecurityBundle\DependencyInjection\Security\Factory; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
6
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
7
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator; |
8
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
9
|
|
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; |
10
|
|
|
|
11
|
|
|
class RequestSignatureFactory implements SecurityFactoryInterface |
12
|
|
|
{ |
13
|
|
|
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) |
14
|
|
|
{ |
15
|
|
|
$signatureQueryParametersId = $this->createSignatureQueryParameters($container, $id, $config); |
16
|
|
|
$signatureConfigId = $this->createSignatureConfig($container, $id, $config); |
17
|
|
|
$replayProtectionId = $this->createReplayProtection($container, $id, $config); |
18
|
|
|
$providerId = 'security.authentication.provider.request_signature.'.$id; |
19
|
|
|
|
20
|
|
|
$container |
21
|
|
|
->setDefinition($providerId, new DefinitionDecorator('rezzza.security.request_signature.provider')) |
|
|
|
|
22
|
|
|
->addArgument(new Reference($signatureConfigId)) |
23
|
|
|
->addArgument(new Reference($replayProtectionId)) |
24
|
|
|
; |
25
|
|
|
|
26
|
|
|
$listenerId = 'security.authentication.listener.request_signature.'.$id; |
27
|
|
|
$listener = $container |
|
|
|
|
28
|
|
|
->setDefinition($listenerId, new DefinitionDecorator('rezzza.security.request_signature.listener')) |
|
|
|
|
29
|
|
|
->replaceArgument(2, new Reference($signatureQueryParametersId)) |
30
|
|
|
->replaceArgument(3, $config['ignore']) |
31
|
|
|
; |
32
|
|
|
|
33
|
|
|
return array($providerId, $listenerId, $defaultEntryPoint); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getPosition() |
37
|
|
|
{ |
38
|
|
|
return 'pre_auth'; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getKey() |
42
|
|
|
{ |
43
|
|
|
return 'request_signature'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function createSignatureConfig($container, $id, $config) |
47
|
|
|
{ |
48
|
|
|
$signatureConfigId = 'rezzza.security.request_signature.signature_config.'.$id; |
49
|
|
|
$container |
50
|
|
|
->setDefinition($signatureConfigId, new DefinitionDecorator('rezzza.security.request_signature.signature_config')) |
|
|
|
|
51
|
|
|
->addArgument($config['replay_protection']['enabled']) |
52
|
|
|
->addArgument($config['algorithm']) |
53
|
|
|
->addArgument($config['secret']) |
54
|
|
|
; |
55
|
|
|
|
56
|
|
|
return $signatureConfigId; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function createSignatureQueryParameters($container, $id, $config) |
60
|
|
|
{ |
61
|
|
|
$signatureQueryParametersId = 'rezzza.security.request_signature.signature_query_parameters.'.$id; |
62
|
|
|
$container |
63
|
|
|
->setDefinition($signatureQueryParametersId, new DefinitionDecorator('rezzza.security.request_signature.signature_query_parameters')) |
|
|
|
|
64
|
|
|
->addArgument($config['parameter']) |
65
|
|
|
->addArgument($config['replay_protection']['parameter']) |
66
|
|
|
; |
67
|
|
|
|
68
|
|
|
return $signatureQueryParametersId; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function createReplayProtection($container, $id, $config) |
72
|
|
|
{ |
73
|
|
|
$replayProtectionId = 'rezzza.security.request_signature.replay_protection.'.$id; |
74
|
|
|
$container |
75
|
|
|
->setDefinition($replayProtectionId, new DefinitionDecorator('rezzza.security.request_signature.replay_protection')) |
|
|
|
|
76
|
|
|
->addArgument($config['replay_protection']['enabled']) |
77
|
|
|
->addArgument($config['replay_protection']['lifetime']) |
78
|
|
|
; |
79
|
|
|
|
80
|
|
|
return $replayProtectionId; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function addConfiguration(NodeDefinition $node) |
84
|
|
|
{ |
85
|
|
|
$node->children() |
|
|
|
|
86
|
|
|
->scalarNode('algorithm')->defaultValue('SHA1')->cannotBeEmpty()->end() |
87
|
|
|
->scalarNode('secret')->isRequired()->cannotBeEmpty()->end() |
88
|
|
|
->booleanNode('ignore')->defaultFalse()->end() |
89
|
|
|
->scalarNode('parameter')->defaultValue('_signature')->cannotBeEmpty()->end() |
90
|
|
|
->arrayNode('replay_protection') |
91
|
|
|
->addDefaultsIfNotSet() |
92
|
|
|
->children() |
93
|
|
|
->booleanNode('enabled')->defaultTrue()->end() |
94
|
|
|
->scalarNode('lifetime')->defaultValue(600)->end() |
95
|
|
|
->scalarNode('parameter')->defaultValue('_signature_time')->cannotBeEmpty()->end() |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.