简体   繁体   中英

Security in Symfony2

I've created a Bundle named "User". In the general routing I added /user to every UserBundle url. So, for example, when I define the route /list in the UserBundle the real path is http://myapp.loc/user/list .

I'm trying to force user to login to use this website, an I'm doing this:

security:
       firewalls:
          login_firewall:
              pattern:    ^/user/login
              anonymous:  ~
          secured_area:
              pattern:    ^/
              form_login:
                   login_path: user_login
                   check_path: user_login_check
                   default_target_path: /
              logout:
                   path: /user_logout
                   target: user_login
              remember_me:
                    key:      atipics-soft2012
                    lifetime: 3600           
       access_control:
           - { path: ^/, roles: ROLE_USER }
       providers:
           users:
               entity: { class: MyApp\UserBundle\Entity\User, property:email }
       encoders:
           MyApp\UserBundle\Entity\User: { algorithm:  sha512, iterations: 10 }

I'm getting an error like this:

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

What could be the problem?

Of couse I've added this route in the routes file.

I don't know if it's a bug or was intented this way, but check_path doesn't accept route names. You have to set it to a path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM