|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ma27\ApiKeyAuthenticationBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
7
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
|
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
|
|
|
class Configuration implements ConfigurationInterface |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* {@inheritdoc} |
|
18
|
|
|
*/ |
|
19
|
10 |
|
public function getConfigTreeBuilder() |
|
20
|
|
|
{ |
|
21
|
10 |
|
$treeBuilder = new TreeBuilder(); |
|
22
|
10 |
|
$rootNode = $treeBuilder->root('ma27_api_key_authentication'); |
|
23
|
|
|
|
|
24
|
|
|
$rootNode |
|
25
|
10 |
|
->children() |
|
26
|
10 |
|
->arrayNode('user') |
|
27
|
10 |
|
->children() |
|
28
|
10 |
|
->integerNode('api_key_length') |
|
29
|
10 |
|
->min(50) |
|
30
|
10 |
|
->defaultValue(200) |
|
31
|
10 |
|
->end() |
|
32
|
10 |
|
->scalarNode('object_manager')->isRequired()->end() |
|
33
|
10 |
|
->scalarNode('model_name')->defaultValue('AppBundle:User')->end() |
|
34
|
10 |
|
->arrayNode('password') |
|
35
|
10 |
|
->children() |
|
36
|
|
|
->scalarNode('strategy') |
|
37
|
|
|
->validate() |
|
38
|
9 |
|
->ifNotInArray(array('php55', 'crypt', 'sha512', 'phpass')) |
|
39
|
9 |
|
->thenInvalid( |
|
40
|
9 |
|
'Invalid password strategy "%s"! ' |
|
41
|
|
|
.'Allowed strategies are "password", "crypt", "sha512", "phpass"!' |
|
42
|
9 |
|
) |
|
43
|
1 |
|
->end() |
|
44
|
|
|
->end() |
|
45
|
|
|
->integerNode('phpass_iteration_length') |
|
46
|
8 |
|
->defaultValue(8) |
|
47
|
1 |
|
->end() |
|
48
|
1 |
|
->end() |
|
49
|
1 |
|
->end() |
|
50
|
1 |
|
->end() |
|
51
|
|
|
->end() |
|
52
|
1 |
|
->arrayNode('api_key_purge') |
|
53
|
|
|
->canBeEnabled() |
|
54
|
1 |
|
->children() |
|
55
|
1 |
|
->booleanNode('log_state')->defaultFalse()->end() |
|
56
|
1 |
|
->scalarNode('logger_service')->defaultValue('logger')->end() |
|
57
|
1 |
|
->end() |
|
58
|
1 |
|
->end() |
|
59
|
1 |
|
->arrayNode('services') |
|
60
|
|
|
->addDefaultsIfNotSet() |
|
61
|
|
|
->children() |
|
62
|
7 |
|
->scalarNode('auth_handler')->defaultNull()->end() |
|
63
|
10 |
|
->scalarNode('key_factory')->defaultNull()->end() |
|
64
|
10 |
|
->scalarNode('password_hasher')->defaultNull()->end() |
|
65
|
10 |
|
->end() |
|
66
|
10 |
|
->end() |
|
67
|
10 |
|
->end(); |
|
68
|
10 |
|
|
|
69
|
10 |
|
return $treeBuilder; |
|
70
|
10 |
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|