I am extending the authentication failure handler and everything is mainly working ok, but for one small problem.
This is my services.yml:
http.utils.class:
class: Symfony\Component\Security\Http\HttpUtils
auth.fail:
class: Acme\MyBundle\AuthenticationFailure
arguments:
- @http_kernel
- @http.utils.class
- []
I have set this to be used in security.yml:
failure_handler: auth.fail
This is my Acme\MyBundle\AuthenticationFailure.php:
namespace Acme\MyBundle;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
use Symfony\Component\HttpFoundation\Response;
class AuthenticationFailure extends DefaultAuthenticationFailureHandler
{
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
//do something
}
}
The problem is that the options I've set in security.yml are ignored. I know the third parameter of the _construct method of the class is the $options array, and I've not passed anything in as the third parameter (in services.yml), so I'm guessing this is the problem and a solution could be to just pass the values in. I'm guessing I could also do something like this:
arguments:
- @http_kernel
- @http.utils.class
- %security.firewalls.secure_area.form_login%
....I've not tested as the problem is this is hard-coding that in services.yml and it isn't ideal as if I changed the name of secure_area it would break. Surely these values are available in a better way?