Configuration.php 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace JMS\SecurityExtraBundle\DependencyInjection;
  18. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  19. use Symfony\Component\Config\Definition\ConfigurationInterface;
  20. class Configuration implements ConfigurationInterface
  21. {
  22. public function getConfigTreeBuilder()
  23. {
  24. $tb = new TreeBuilder();
  25. $tb
  26. ->root('jms_security_extra')
  27. ->validate()
  28. ->always(function($v) {
  29. if ($v['method_access_control'] && !$v['expressions']) {
  30. throw new \Exception('You need to enable expressions if you want to configure method access via the DI config.');
  31. }
  32. return $v;
  33. })
  34. ->end()
  35. ->children()
  36. ->booleanNode('secure_all_services')->defaultFalse()->end()
  37. ->booleanNode('enable_iddqd_attribute')->defaultFalse()->end()
  38. ->scalarNode('cache_dir')->cannotBeEmpty()->defaultValue('%kernel.cache_dir%/jms_security')->end()
  39. ->booleanNode('expressions')->defaultFalse()->end()
  40. ->arrayNode('voters')
  41. ->addDefaultsIfNotSet()
  42. ->canBeUnset()
  43. ->children()
  44. ->booleanNode('disable_authenticated')->defaultFalse()->end()
  45. ->booleanNode('disable_role')->defaultFalse()->end()
  46. ->booleanNode('disable_acl')->defaultFalse()->end()
  47. ->end()
  48. ->end()
  49. ->arrayNode('method_access_control')
  50. ->useAttributeAsKey('pattern')
  51. ->prototype('scalar')->isRequired()->cannotBeEmpty()->end()
  52. ->end()
  53. ->arrayNode('util')
  54. ->addDefaultsIfNotSet()
  55. ->children()
  56. ->arrayNode('secure_random')
  57. ->children()
  58. ->scalarNode('connection')->cannotBeEmpty()->end()
  59. ->scalarNode('table_name')->defaultValue('seed_table')->cannotBeEmpty()->end()
  60. ->scalarNode('seed_provider')->cannotBeEmpty()->end()
  61. ->end()
  62. ->end()
  63. ->end()
  64. ->end()
  65. ->end()
  66. ->end()
  67. ;
  68. return $tb;
  69. }
  70. }