I'm trying to setup a backend and frontend firewall system in Symfony 2. I have two login forms, one for the frontend and another one for the admin control panel. Different providers and so on. My configuration looks like this:
security:
    firewalls:
        backend:
            pattern:    ^/admin
            anonymous:  true
            provider:   admin_users
            form_login:
                login_path: /admin/login
                check_path: /admin/login_check
                default_target_path: /admin
        secured_area:
            pattern:    ^/
            provider:   normal_users
            anonymous:  true
            form_login: ~
    access_control:
        - { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin, roles: ROLE_ADMIN }
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
And my routing.yml:
login:
    path:     /login
    defaults: { _controller: MyFrontendBundle:Default:login }
login_check:
    path:     /login_check
admin_login:
    path:     /admin/login
    defaults: { _controller: MyBackendBundle:Default:login }
admin_login_check:
    path:     /admin/login_check
Seems right, but i'm having the following error: Unable to find the controller for path "/admin/login_check". Maybe you forgot to add the matching route in your routing configuration
Any ideas? :)
This solution I use in my projects. Hope this will work with two login forms too.
Add stub for controller
admin_login_check:
    path:     /admin/login_check
    defaults: { _controller: AcmeDemoBundle:Default:adminLoginCheck }
Action stub. This action will never be reached, but "controller not found" error will gone.
// src/Acme/DemoBundle/Controller/DefaultController.php
public function adminLoginCheckAction()
{
    return $this->redirect($this->generateUrl('admin_login'));
}
                        Your url mapping seems to be right,
Please check if you have correct check_path (/admin/login_check) in your admin controller.
or
Try adding login_check under access_control as below,
- { path: ^/admin/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
I had similar issue when I was trying to use firewalls with overlapping url patterns. The first firewall did not have check_path ( I was using http_basic in first firewall) and in second firwall I was using form_login. I had to change URL mapping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With