I need to write a basic authentication handler. In my onAuthenticationFailure, just for testing, i’m var-dumping $request. it should work using bad credentials, but nothing happened.
I guess there is something wrong in my src\Acme\TestBundle\resources\Config\services.yml:
services:
authentication_handler:
class: Acme\TestBundle\Handler\AuthenticationHandler
This is the test class, use statement removed for readability:
namespace Acme\TestBundle\Handler;
class AuthenticationHandler implements AuthenticationSuccessHandlerInterface,
AuthenticationFailureHandlerInterface, LogoutSuccessHandlerInterface
{
function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$user = $token->getUser();
}
function onAuthenticationFailure(Request $request,
AuthenticationException $exception)
{
var_dump($request);
die();
}
public function onLogoutSuccess(Request $request)
{
}
}
You need to set the handler in the
security.ymlfile: