I am using FOSUserBundle for admin section as well as frontend by following the instructions given at:
https://github.com/FriendsOfSymfony/FOSUserBundle/issu
@neeraj, as an answer to your comment here FOSUserBundle admin area not accessible after login as i know it's not possible to do it only with security.yml, but you can go with listener, not much to do.
create folder EventListener in your Bundle, then create SecurityListener.php
router = $router;
$this->security = $security;
$this->dispatcher = $dispatcher;
}
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
}
public function onKernelResponse(FilterResponseEvent $event)
{
if ($this->security->isGranted('ROLE_ADMIN')) {
$response = new RedirectResponse($this->router->generate('YOURCoreBundle_adminpage'));
} elseif ($this->security->isGranted('ROLE_USER')) {
$response = new RedirectResponse($this->router->generate('YOURBundle_userpage'));
} else {
$response = new RedirectResponse($this->router->generate('YOURCoreBundle_homepage'));
}
$event->setResponse($response);
}
}
and in services.xml add
Your\NameBundle\EventListener\SecurityListener