I want to configure my security.yml in my project to require HTTP Basic authentication from all hosts excluding localhost? Is it possible? I have failed to find a solution on the Web.
-
did you try the regexp negation in the security pattern?Max Małecki– Max Małecki2012-10-30 13:41:26 +00:00Commented Oct 30, 2012 at 13:41
-
1Can you can give me any example of that solution?mrzepinski– mrzepinski2012-10-30 17:44:12 +00:00Commented Oct 30, 2012 at 17:44
Add a comment
|
1 Answer
You could create a request matcher.
You can follow this great tutorial to enable the request matcher http://php-and-symfony.matthiasnoback.nl/2012/07/symfony2-security-using-advanced-request-matchers-to-activate-firewalls/
Only follow the "Creating an advanced request matcher" and "Hook the request matcher in the security configuration" sections though.
Your match method would look like this:
return 'localhost' == $request->getHost();