7
7
use Symfony \Component \Config \Definition \ConfigurationInterface ;
8
8
9
9
/**
10
- * The Library configuration. You'll find here all configuration possible. Used when instanciating the library.
10
+ * The Library configuration. You'll find here all configuration possible. Used when instantiating the library.
11
11
*
12
12
* @author CrowdSec team
13
13
*
@@ -21,32 +21,54 @@ class Configuration implements ConfigurationInterface
21
21
/**
22
22
* {@inheritdoc}
23
23
*/
24
- public function getConfigTreeBuilder ()
24
+ public function getConfigTreeBuilder (): TreeBuilder
25
25
{
26
26
$ treeBuilder = new TreeBuilder ('config ' );
27
27
/** @var $rootNode ArrayNodeDefinition */
28
28
$ rootNode = $ treeBuilder ->getRootNode ();
29
29
$ rootNode
30
30
->children ()
31
- ->scalarNode ('api_key ' )->isRequired ()->end ()
32
- ->scalarNode ('api_url ' )->defaultValue (Constants::CAPI_URL )->end ()
33
- ->scalarNode ('api_user_agent ' )->defaultValue (Constants::BASE_USER_AGENT )->end ()
34
- ->integerNode ('api_timeout ' )->defaultValue (Constants::API_TIMEOUT )->end ()
35
- ->booleanNode ('live_mode ' )->defaultValue (true )->end ()
36
- ->enumNode ('max_remediation_level ' )
37
- ->values (Constants::ORDERED_REMEDIATIONS )
38
- ->defaultValue (Constants::REMEDIATION_BAN )
39
- ->end ()
40
- ->enumNode ('fallback_remediation ' )
41
- ->values (Constants::ORDERED_REMEDIATIONS )
42
- ->defaultValue (Constants::REMEDIATION_CAPTCHA )
43
- ->end ()
44
- ->integerNode ('cache_expiration_for_clean_ip ' )
45
- ->defaultValue (Constants::CACHE_EXPIRATION_FOR_CLEAN_IP )
46
- ->end ()
47
- ->integerNode ('cache_expiration_for_bad_ip ' )
48
- ->defaultValue (Constants::CACHE_EXPIRATION_FOR_BAD_IP )
49
- ->end ()
31
+ ->scalarNode ('api_key ' )->isRequired ()->end ()
32
+ ->scalarNode ('api_url ' )->defaultValue (Constants::CAPI_URL )->end ()
33
+ ->scalarNode ('api_user_agent ' )->defaultValue (Constants::BASE_USER_AGENT )->end ()
34
+ ->integerNode ('api_timeout ' )->defaultValue (Constants::API_TIMEOUT )->end ()
35
+ ->booleanNode ('live_mode ' )->defaultValue (true )->end ()
36
+ ->enumNode ('max_remediation_level ' )
37
+ ->values (Constants::ORDERED_REMEDIATIONS )
38
+ ->defaultValue (Constants::REMEDIATION_BAN )
39
+ ->end ()
40
+ ->enumNode ('fallback_remediation ' )
41
+ ->values (Constants::ORDERED_REMEDIATIONS )
42
+ ->defaultValue (Constants::REMEDIATION_CAPTCHA )
43
+ ->end ()
44
+ ->integerNode ('cache_expiration_for_clean_ip ' )
45
+ ->defaultValue (Constants::CACHE_EXPIRATION_FOR_CLEAN_IP )
46
+ ->end ()
47
+ ->integerNode ('cache_expiration_for_bad_ip ' )
48
+ ->defaultValue (Constants::CACHE_EXPIRATION_FOR_BAD_IP )
49
+ ->end ()
50
+ ->arrayNode ('geolocation ' )
51
+ ->addDefaultsIfNotSet ()
52
+ ->children ()
53
+ ->booleanNode ('enabled ' )
54
+ ->isRequired ()
55
+ ->defaultFalse ()
56
+ ->end ()
57
+ ->enumNode ('type ' )
58
+ ->isRequired ()
59
+ ->defaultValue (Constants::GEOLOCATION_TYPE_MAXMIND )
60
+ ->values ([Constants::GEOLOCATION_TYPE_MAXMIND ])
61
+ ->end ()
62
+ ->arrayNode (Constants::GEOLOCATION_TYPE_MAXMIND )
63
+ ->addDefaultsIfNotSet ()
64
+ ->children ()
65
+ ->scalarNode ('database_path ' )
66
+ ->cannotBeEmpty ()
67
+ ->end ()
68
+ ->end ()
69
+ ->end ()
70
+ ->end ()
71
+ ->end ()
50
72
->end ();
51
73
52
74
return $ treeBuilder ;
0 commit comments