I run first time into a problem with Symfony (2.7) authentication, where I really couldn't find a working solution. Although Symfony has a dedicated configuration option logout -> target, this gets never applied on logouts, I always get directed to /. I probably missed some constraint on implementing this correctly.
Ok, I'm using:
- Form based login
- Hooked custom failure, success and logout handlers, which are working perfectly
My config.yml firewall
secured_area:
pattern: ^/
stateless: false
form_login:
...
logout:
path: logout
target: /test
success_handler: logout_success_handler
anonymous: ~
For testing I even added
access_control:
- { path: ^/test, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
I'm using route-names for the paths, the route exists and are working ok (I can login, login_check and logout).
My expectation by setting logout -> target, that on logout I get redirected to the page /test. But whatever I tried, until now I'm always on / after logout.
I would be very glad, if somebody can point me into the correct direction, how to logout to a custom route (I also tried already target with a route name). Many thanks!
BTW:
My logout_success_handler does currently nothing. By enabling the dump, I just also see, that the redirection is always going to / and not to /test.
public function onLogoutSuccess(Request $request)
{
$response = parent::onLogoutSuccess($request);
//var_dump($response); die;
return $response;
}