我有一个onKernelResponse侦听器。在我的代码中,我想知道用户是否请求防火墙url。我想设置var $isRequestToAProtectedUrl
...
if( $isAjaxRequest && !$isAuthenticated && $isRequestToAProtectedUrl){
$this->container->get("session")->invalidate();
header('NOT_AUTHORIZED: 499'); //modifiy header(must be catch in client)
exit();
}
...
thanks in advance
Symfony2 Security为您解决身份验证和授权问题。似乎您需要创建自定义AccessDeniedHandler。这里有一个很好的例子:
使用Symfony2's AccessDeniedHandlerInterface