mrzepinski
mrzepinski

Reputation: 419

Symfony2 Basic Auth Athentication except localhost

I want to configure my security.yml in my project to require Basic Auth from all hosts excluding localhost? Is it possible? I've tried to found solution on the Web, but ineffective.

Upvotes: 0

Views: 262

Answers (1)

AdrienBrault
AdrienBrault

Reputation: 7745

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();

Upvotes: 1

Related Questions