Oriam
Oriam

Reputation: 641

How to know if a request is been made to a protected url

i have a onKernelResponse listener. in my code i want to know if the user request a firewalled url or not. I want to set my 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

Upvotes: 0

Views: 57

Answers (1)

tomas.pecserke
tomas.pecserke

Reputation: 3260

Symfony2 Security solves authentication and authorization for you. It seems you need to create custom AccessDeniedHandler. There is a nice example here:
Using Symfony2's AccessDeniedHandlerInterface

Upvotes: 1

Related Questions