0

我有一个 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();
}
...

提前致谢

4

1 回答 1

1

Symfony2 Security 为您解决身份验证和授权问题。看来您需要创建自定义 AccessDeniedHandler。这里有一个很好的例子:
Using Symfony2's AccessDeniedHandlerInterface

于 2013-04-06T10:01:38.093 回答