symfony2 get firewall name on login page
authentication, firewall, security, symfony
Solution
As of symfony 3.2, you can now get the current firewall configuration using the following:
public function indexAction(Request $request)
{
$firewall = $this->container
->get('security.firewall.map')
->getFirewallConfig($request)
->getName();
}
Ref: http://symfony.com/blog/new-in-symfony-3-2-firewall-config-class-and-profiler
Problem
I'd want to use a login page to access different firewalls, so I need to get information about the firewall I'm logging in. In my controller I'd use ``` $this->container->get('security.context')->getToken()->getProviderKey() ``` but as an anonymous user I don't have access to getProviderKey method. I could also parse ``` _security.xxx.target_path ``` to get xxx firewall but I'm looking for a more general solution if it exists at all. Any idea?