Mario Gonzalez Munzon
Mario Gonzalez Munzon

Reputation: 157

The check_path for login method is not matched by the firewall pattern

I'm configuring the security layer for a login form on Symfony2, but this error keeps emerging:

InvalidConfigurationException: Invalid configuration for path 
"security.firewalls.gestor_area": The check_path "^/ES/gestor/login_check" 
for login method "form_login" is not matched by the firewall pattern "^/ES/gestor".

The relevant part of security.yml is:

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    gestor_area:
        pattern: ^/ES/gestor
        http_basic: ~
        provider: db
        form_login:
            login_path: weblogin_login
            check_path: ^/ES/gestor/login_check

    access_control: 
           - { path: ^/ES/gestor, roles: ROLE_ADMIN } 
           - { path: weblogin_login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
           - { path: ^/ES/gestor/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
           - { path: ^/PT/project, roles: ROLE_ADMIN } 
           - { path: ^/FR/project, roles: ROLE_ADMIN } 
           - { path: ^/CL/project, roles: ROLE_ADMIN } 
           - { path: ^/ES/project, roles: ROLE_ADMIN } 
           - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }

Made it fully work http autentification -- also displaying the login form, but when I try to authenticate with the login form it crashes, or it just display this error.

How do I set the route to match with the firewall pattern?

UPDATE: Added paths to Access Control, still doesn't work, same error.

Upvotes: 3

Views: 3999

Answers (3)

user6830821
user6830821

Reputation:

You can use my admin fire wall it works for me. I use jms i18n translation rooting bundle with fos user bundle and sonata admin bundle.

    admin:
        pattern:            /admin(.*)
        context:            user
        form_login:
            provider:       fos_userbundle
            login_path:     sonata_user_admin_security_login
            use_forward:    false
            check_path:     sonata_user_admin_security_check
            failure_path:   null
        logout:
            path:           sonata_user_admin_security_logout
        anonymous:          true

Upvotes: 0

kinghfb
kinghfb

Reputation: 1021

There's a typo in:

The check_path "^/ES/gestor/login_check"

This check_path should be a plain text path and not a regex pattern. i.e. Leave out the ^ character in your case.

Upvotes: 4

ccab
ccab

Reputation: 17

Following the Symfony Best Practices:

Unless you have two legitimately different authentication systems and users (e.g. form login for the main site and a token system for your API only), we recommend having only one firewall entry with the anonymous key enabled.

So your configuration settings could be like this:

firewalls:
    secured_area:
        pattern: ^/
        anonymous: true
        form_login:
            check_path: security_login_check
            login_path: security_login_form

Take a look at the chapter for more information

Upvotes: -3

Related Questions