|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DoL\LdapBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
6
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
7
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
|
11
|
|
|
* |
|
12
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
|
13
|
|
|
* |
|
14
|
|
|
* @author DarwinOnLine |
|
15
|
|
|
* @author Maks3w |
|
16
|
|
|
* |
|
17
|
|
|
* @see https://github.com/DarwinOnLine/DoLLdapBundle |
|
18
|
|
|
*/ |
|
19
|
|
|
class Configuration implements ConfigurationInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* {@inheritdoc} |
|
23
|
|
|
*/ |
|
24
|
6 |
|
public function getConfigTreeBuilder() |
|
25
|
|
|
{ |
|
26
|
6 |
|
$treeBuilder = new TreeBuilder(); |
|
27
|
6 |
|
$rootNode = $treeBuilder->root('dol_ldap'); |
|
28
|
|
|
|
|
29
|
|
|
$rootNode |
|
30
|
6 |
|
->children() |
|
31
|
6 |
|
->arrayNode('domains') |
|
32
|
6 |
|
->useAttributeAsKey('id') |
|
33
|
6 |
|
->prototype('array') |
|
34
|
6 |
|
->children() |
|
35
|
6 |
|
->arrayNode('driver') |
|
36
|
6 |
|
->children() |
|
37
|
6 |
|
->scalarNode('host')->isRequired()->cannotBeEmpty()->end() |
|
38
|
6 |
|
->scalarNode('port')->defaultValue(389)->end() |
|
39
|
6 |
|
->scalarNode('useStartTls')->defaultFalse()->end() |
|
40
|
6 |
|
->scalarNode('useSsl')->defaultFalse()->end() |
|
41
|
6 |
|
->scalarNode('username')->end() |
|
42
|
6 |
|
->scalarNode('password')->end() |
|
43
|
6 |
|
->scalarNode('bindRequiresDn')->defaultFalse()->end() |
|
44
|
6 |
|
->scalarNode('baseDn')->end() |
|
45
|
6 |
|
->scalarNode('accountCanonicalForm')->end() |
|
46
|
6 |
|
->scalarNode('accountDomainName')->end() |
|
47
|
6 |
|
->scalarNode('accountDomainNameShort')->end() |
|
48
|
6 |
|
->scalarNode('accountFilterFormat')->end() |
|
49
|
6 |
|
->scalarNode('allowEmptyPassword')->end() |
|
50
|
6 |
|
->scalarNode('optReferrals')->end() |
|
51
|
6 |
|
->scalarNode('tryUsernameSplit')->end() |
|
52
|
6 |
|
->scalarNode('networkTimeout')->end() |
|
53
|
6 |
|
->end() |
|
54
|
6 |
|
->validate() |
|
55
|
|
|
->ifTrue(function ($v) { |
|
56
|
6 |
|
return $v['useSsl'] && $v['useStartTls']; |
|
57
|
6 |
|
}) |
|
58
|
6 |
|
->thenInvalid('The useSsl and useStartTls options are mutually exclusive.') |
|
59
|
6 |
|
->end() |
|
60
|
6 |
|
->end() |
|
61
|
6 |
|
->arrayNode('user') |
|
62
|
6 |
|
->children() |
|
63
|
6 |
|
->scalarNode('baseDn')->isRequired()->cannotBeEmpty()->end() |
|
64
|
6 |
|
->scalarNode('filter')->defaultValue('')->end() |
|
65
|
6 |
|
->scalarNode('usernameAttribute')->defaultValue('uid')->end() |
|
66
|
6 |
|
->arrayNode('attributes') |
|
67
|
6 |
|
->defaultValue(array( |
|
68
|
|
|
array( |
|
69
|
6 |
|
'ldap_attr' => 'uid', |
|
70
|
6 |
|
'user_method' => 'setUsername', ), |
|
71
|
6 |
|
)) |
|
72
|
6 |
|
->prototype('array') |
|
73
|
6 |
|
->children() |
|
74
|
6 |
|
->scalarNode('ldap_attr')->isRequired()->cannotBeEmpty()->end() |
|
75
|
6 |
|
->scalarNode('user_method')->isRequired()->cannotBeEmpty()->end() |
|
76
|
6 |
|
->end() |
|
77
|
6 |
|
->end() |
|
78
|
6 |
|
->end() |
|
79
|
6 |
|
->end() |
|
80
|
6 |
|
->end() |
|
81
|
6 |
|
->end() |
|
82
|
6 |
|
->validate() |
|
83
|
6 |
|
->ifTrue(function ($v) { |
|
84
|
5 |
|
return $v['driver']['useSsl'] && $v['driver']['useStartTls']; |
|
85
|
6 |
|
}) |
|
86
|
6 |
|
->thenInvalid('The useSsl and useStartTls options are mutually exclusive.') |
|
87
|
6 |
|
->end() |
|
88
|
6 |
|
->end() |
|
89
|
6 |
|
->end(); |
|
90
|
|
|
|
|
91
|
6 |
|
$this->addServiceSection($rootNode); |
|
92
|
|
|
|
|
93
|
6 |
|
return $treeBuilder; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
6 |
|
private function addServiceSection(ArrayNodeDefinition $node) |
|
97
|
|
|
{ |
|
98
|
|
|
$node |
|
99
|
6 |
|
->addDefaultsIfNotSet() |
|
100
|
6 |
|
->children() |
|
101
|
6 |
|
->arrayNode('service') |
|
102
|
6 |
|
->addDefaultsIfNotSet() |
|
103
|
6 |
|
->children() |
|
104
|
6 |
|
->scalarNode('user_hydrator')->defaultValue('dol_ldap.user_hydrator.default')->end() |
|
105
|
6 |
|
->scalarNode('ldap_manager')->defaultValue('dol_ldap.ldap_manager.default')->end() |
|
|
|
|
|
|
106
|
6 |
|
->scalarNode('ldap_driver')->defaultValue('dol_ldap.ldap_driver.zend')->end() |
|
107
|
6 |
|
->end() |
|
108
|
6 |
|
->end() |
|
109
|
6 |
|
->end() |
|
110
|
6 |
|
->end(); |
|
111
|
6 |
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|