I do not think you can use routes in the access_control configuration. Instead, try providing an alternate path, IE:
- { path: ^/wsoa, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
Then the routes to be protected use the prefix.
wsoa_products_tests: pattern: /wsoa/tests defaults: { _controller: WsoaProductsBundle:Test:display }
Edit:
You can try creating a custom voter .. ( http://symfony.com/doc/2.0/cookbook/security/voters.html )
Use the class suggested in this document, and then you can impose a voting method on something like:
function vote(TokenInterface $token, $object, array $attributes) { $request = $this->container->get('request'); $route = $request->get('_route'); // I suggest passing the allowed routes in the service definition instead of // hardcoding here, but for example sake: if (in_array($route, array('wsoa_product_tests'))) { if (in_array($request->getClientIp(), $this->blacklistedIp)) { return VoterInterface::ACCESS_DENIED; } } return VoterInterface::ACCESS_ABSTAIN; }
source share