1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Azine\GeoBlockingBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the class that validates and merges configuration from your app/config files |
10
|
|
|
* |
11
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
12
|
|
|
*/ |
13
|
|
|
class Configuration implements ConfigurationInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritDoc} |
17
|
|
|
*/ |
18
|
4 |
|
public function getConfigTreeBuilder() |
19
|
|
|
{ |
20
|
4 |
|
$treeBuilder = new TreeBuilder(); |
21
|
4 |
|
$rootNode = $treeBuilder->root('azine_geo_blocking'); |
22
|
|
|
|
23
|
|
|
$rootNode |
24
|
4 |
|
->children() |
25
|
4 |
|
->booleanNode ("enabled") ->defaultTrue()->info("true|false : turn the whole bundle on/off")->end() |
26
|
4 |
|
->scalarNode ('access_denied_view') ->defaultValue('AzineGeoBlockingBundle::accessDenied.html.twig')->info("the view to be rendered as 'blocked' page")->end() |
27
|
4 |
|
->booleanNode ('block_anonymouse_users_only') ->defaultTrue()->info("block all users or only users that are not logged in yet")->end() |
28
|
4 |
|
->scalarNode ('login_route') ->defaultValue('fos_user_security_login')->info("route name to the login-form (only relevant if block_anonymouse_users_only is set to true)")->end() |
29
|
4 |
|
->scalarNode ('lookup_adapter') ->defaultValue('azine_geo_blocking.default.lookup.adapter')->info("id of the lookup-adapter you would like to use")->end() |
30
|
4 |
|
->booleanNode ('allow_private_ips') ->defaultTrue()->info("true | false : also applie the rules to private IPs e.g. 127.0.0.1 or 192.168.xxx.yyy etc.")->end() |
31
|
4 |
|
->variableNode ('ip_whitelist') ->defaultValue(array())->info("List of IPs (or regexp for IPs) you would like to allow. E.g. Search engine crawlers")->end() |
32
|
4 |
|
->scalarNode ('logBlockedRequests') ->defaultFalse()->info("true | false : Log a message for blocked request.")->end() |
33
|
4 |
|
->scalarNode ('allow_search_bots') ->defaultFalse()->info("true | false : Allow Bing and Google crawlers.")->end() |
34
|
4 |
|
->variableNode ('search_bot_domains') ->defaultValue(array(".google.com", ".googlebot.com", ".search.msn.com"))->info("array of domains of allowed search-engine-bots e.g. .googlebot.com or .search.msn.com")->end() |
35
|
4 |
|
->arrayNode ('countries') ->info("only whitelist or blacklist can contain values.")->addDefaultsIfNotSet() |
36
|
4 |
|
->children() |
37
|
4 |
|
->variableNode('blacklist')->defaultValue(array())->info("e.g. 'US','CN' etc. => access is denied to visitors from these countries")->end() |
38
|
4 |
|
->variableNode('whitelist')->defaultValue(array())->info("e.g. 'CH','FR','DE' etc. => access is allowed to visitors from these countries")->end() |
39
|
4 |
|
->end() |
40
|
4 |
|
->end()// end countries |
41
|
4 |
|
->arrayNode ('routes')->info("only whitelist or blacklist can contain values.")->addDefaultsIfNotSet() |
42
|
4 |
|
->children() |
43
|
4 |
|
->variableNode('blacklist')->defaultValue(array())->info("list of routes, that always should be blocked for access from unliked locations.")->end() |
44
|
4 |
|
->variableNode('whitelist')->defaultValue(array('fos_user_security_login', 'fos_user_security_login_check', 'fos_user_security_logout'))->info("list of routes, that never should be blocked for access from unliked locations (e.g. the login-routes).")->end() |
45
|
4 |
|
->end() |
46
|
4 |
|
->end()// end routes |
47
|
4 |
|
->booleanNode ("allow_by_cookie") ->defaultFalse()->info("true|false : turn the 'allow by cookie' feature on/off")->end() |
48
|
4 |
|
->scalarNode ("allow_by_cookie_name") ->defaultValue("geoblocking_allow_cookie")->info("name of the 'allow_by_cookie'-cookie")->end()
|
49
|
|
|
|
50
|
4 |
|
->end(); |
51
|
|
|
|
52
|
4 |
|
return $treeBuilder; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|