1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace FSi\Bundle\AdminSecurityBundle\DependencyInjection; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
13
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
14
|
|
|
|
15
|
|
|
class Configuration implements ConfigurationInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
*/ |
20
|
|
|
public function getConfigTreeBuilder() |
21
|
|
|
{ |
22
|
|
|
$treeBuilder = new TreeBuilder(); |
23
|
|
|
$rootNode = $treeBuilder->root('fsi_admin_security'); |
24
|
|
|
|
25
|
|
|
$supportedStorages = ['orm']; |
26
|
|
|
|
27
|
|
|
$rootNode |
28
|
|
|
->beforeNormalization() |
29
|
|
|
->always(function($v) { |
30
|
|
|
if (isset($v['mailer']['from'])) { |
31
|
|
|
if (!isset($v['activation']['mailer']['from'])) { |
32
|
|
|
$v['activation']['mailer']['from'] = $v['mailer']['from']; |
33
|
|
|
} |
34
|
|
|
if (!isset($v['password_reset']['mailer']['from'])) { |
35
|
|
|
$v['password_reset']['mailer']['from'] = $v['mailer']['from']; |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if (isset($v['mailer']['reply_to'])) { |
40
|
|
|
if (!isset($v['activation']['mailer']['reply_to'])) { |
41
|
|
|
$v['activation']['mailer']['reply_to'] = $v['mailer']['reply_to']; |
42
|
|
|
} |
43
|
|
|
if (!isset($v['password_reset']['mailer']['reply_to'])) { |
44
|
|
|
$v['password_reset']['mailer']['reply_to'] = $v['mailer']['reply_to']; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $v; |
49
|
|
|
}) |
50
|
|
|
->end() |
51
|
|
|
->children() |
52
|
|
|
->scalarNode('storage') |
53
|
|
|
->validate() |
54
|
|
|
->ifNotInArray($supportedStorages) |
55
|
|
|
->thenInvalid('The driver %s is not supported. Please choose one of ' . json_encode($supportedStorages)) |
56
|
|
|
->end() |
57
|
|
|
->cannotBeOverwritten() |
58
|
|
|
->isRequired() |
59
|
|
|
->cannotBeEmpty() |
60
|
|
|
->end() |
61
|
|
|
->scalarNode('firewall_name')->isRequired()->cannotBeEmpty()->end() |
62
|
|
|
->arrayNode('model') |
63
|
|
|
->isRequired() |
64
|
|
|
->children() |
65
|
|
|
->scalarNode('user')->cannotBeEmpty()->isRequired()->end() |
66
|
|
|
->end() |
67
|
|
|
->end() |
68
|
|
|
->arrayNode('mailer') |
69
|
|
|
->children() |
70
|
|
|
->scalarNode('from')->defaultNull()->end() |
71
|
|
|
->scalarNode('reply_to')->defaultNull()->end() |
72
|
|
|
->end() |
73
|
|
|
->end() |
74
|
|
|
->arrayNode('activation') |
75
|
|
|
->isRequired() |
76
|
|
|
->addDefaultsIfNotSet() |
77
|
|
|
->children() |
78
|
|
|
->integerNode('token_ttl') |
79
|
|
|
->cannotBeEmpty() |
80
|
|
|
->min(0) |
81
|
|
|
->defaultValue(43200) // 12h |
82
|
|
|
->max(172800) // 48h |
83
|
|
|
->end() |
84
|
|
|
->integerNode('token_length') |
85
|
|
|
->cannotBeEmpty() |
86
|
|
|
->min(16) |
87
|
|
|
->defaultValue(32) |
88
|
|
|
->max(64) |
89
|
|
|
->end() |
90
|
|
|
->arrayNode('mailer') |
91
|
|
|
->isRequired() |
92
|
|
|
->addDefaultsIfNotSet() |
93
|
|
|
->children() |
94
|
|
|
->scalarNode('from')->cannotBeEmpty()->isRequired()->end() |
95
|
|
|
->scalarNode('template')->defaultValue('@FSiAdminSecurity/Activation/mail.html.twig')->end() |
96
|
|
|
->scalarNode('reply_to')->defaultNull()->end() |
97
|
|
|
->end() |
98
|
|
|
->end() |
99
|
|
|
->arrayNode('change_password_form') |
100
|
|
|
->addDefaultsIfNotSet() |
101
|
|
|
->children() |
102
|
|
|
->scalarNode('type')->defaultValue('admin_password_reset_change_password')->end() |
103
|
|
|
->arrayNode('validation_groups') |
104
|
|
|
->prototype('scalar')->end() |
105
|
|
|
->defaultValue(['ResetPassword', 'Default']) |
106
|
|
|
->end() |
107
|
|
|
->end() |
108
|
|
|
->end() |
109
|
|
|
->end() |
110
|
|
|
->end() |
111
|
|
|
->arrayNode('password_reset') |
112
|
|
|
->isRequired() |
113
|
|
|
->addDefaultsIfNotSet() |
114
|
|
|
->children() |
115
|
|
|
->integerNode('token_ttl') |
116
|
|
|
->cannotBeEmpty() |
117
|
|
|
->min(0) |
118
|
|
|
->defaultValue(43200) // 12h |
119
|
|
|
->max(172800) // 48h |
120
|
|
|
->end() |
121
|
|
|
->integerNode('token_length') |
122
|
|
|
->cannotBeEmpty() |
123
|
|
|
->min(16) |
124
|
|
|
->defaultValue(32) |
125
|
|
|
->max(64) |
126
|
|
|
->end() |
127
|
|
|
->arrayNode('mailer') |
128
|
|
|
->isRequired() |
129
|
|
|
->addDefaultsIfNotSet() |
130
|
|
|
->children() |
131
|
|
|
->scalarNode('from')->cannotBeEmpty()->isRequired()->end() |
132
|
|
|
->scalarNode('template')->defaultValue('@FSiAdminSecurity/PasswordReset/mail.html.twig')->end() |
133
|
|
|
->scalarNode('reply_to')->defaultNull()->end() |
134
|
|
|
->end() |
135
|
|
|
->end() |
136
|
|
|
->arrayNode('change_password_form') |
137
|
|
|
->addDefaultsIfNotSet() |
138
|
|
|
->children() |
139
|
|
|
->scalarNode('type')->defaultValue('admin_password_reset_change_password')->end() |
140
|
|
|
->arrayNode('validation_groups') |
141
|
|
|
->prototype('scalar')->end() |
142
|
|
|
->defaultValue(['ResetPassword', 'Default']) |
143
|
|
|
->end() |
144
|
|
|
->end() |
145
|
|
|
->end() |
146
|
|
|
->arrayNode('request_form') |
147
|
|
|
->addDefaultsIfNotSet() |
148
|
|
|
->children() |
149
|
|
|
->scalarNode('type')->defaultValue('admin_password_reset_request')->end() |
150
|
|
|
->end() |
151
|
|
|
->end() |
152
|
|
|
->end() |
153
|
|
|
->end() |
154
|
|
|
->arrayNode('change_password') |
155
|
|
|
->addDefaultsIfNotSet() |
156
|
|
|
->children() |
157
|
|
|
->arrayNode('form') |
158
|
|
|
->addDefaultsIfNotSet() |
159
|
|
|
->children() |
160
|
|
|
->scalarNode('type')->defaultValue('admin_change_password')->end() |
161
|
|
|
->arrayNode('validation_groups') |
162
|
|
|
->prototype('scalar')->end() |
163
|
|
|
->defaultValue(['ChangePassword', 'Default']) |
164
|
|
|
->end() |
165
|
|
|
->end() |
166
|
|
|
->end() |
167
|
|
|
->end() |
168
|
|
|
->end() |
169
|
|
|
->arrayNode('templates') |
170
|
|
|
->addDefaultsIfNotSet() |
171
|
|
|
->children() |
172
|
|
|
->scalarNode('login')->defaultValue('FSiAdminSecurityBundle:Security:login.html.twig')->end() |
173
|
|
|
->scalarNode('change_password')->defaultValue('FSiAdminSecurityBundle:Admin:change_password.html.twig')->end() |
174
|
|
|
->arrayNode('activation') |
175
|
|
|
->addDefaultsIfNotSet() |
176
|
|
|
->children() |
177
|
|
|
->scalarNode('change_password')->defaultValue('FSiAdminSecurityBundle:Activation:change_password.html.twig')->end() |
178
|
|
|
->end() |
179
|
|
|
->end() |
180
|
|
|
->arrayNode('password_reset') |
181
|
|
|
->addDefaultsIfNotSet() |
182
|
|
|
->children() |
183
|
|
|
->scalarNode('request')->defaultValue('FSiAdminSecurityBundle:PasswordReset:request.html.twig')->end() |
184
|
|
|
->scalarNode('change_password')->defaultValue('FSiAdminSecurityBundle:PasswordReset:change_password.html.twig')->end() |
185
|
|
|
->end() |
186
|
|
|
->end() |
187
|
|
|
->end() |
188
|
|
|
->end() |
189
|
|
|
->end() |
190
|
|
|
; |
191
|
|
|
|
192
|
|
|
return $treeBuilder; |
193
|
|
|
} |
194
|
|
|
} |
195
|
|
|
|