无法在symfony2.0中找到login_check(我知道它应该是symfony2.4,因为它是解密的,但我的客户想要2.0)。
symfony找不到login_check-path是怎么回事?
我routing.yml:
backend_account_login:
pattern: /{_locale}/secured/login
defaults: { _controller: BackendAccountBundle:Secured:login }
requirements:
_locale: en|de
security_check:
pattern: /{_locale}/secured/login_check
requirements:
_locale: en|de
logout:
pattern: /de/secured/logout
defaults: { _controller: BackendAccountBundle:Secured:logout }
我security.yml :
security:
encoders:
SymfonyComponentSecurityCoreUserUser: plaintext
#Use of an encoder BackendAccoundBundleServices
BackendAccountBundleEntityUser:
id: sha256salted_encoder
role_hierarchy:
ROLE_ADMIN: ROLE_AHA_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
#two providers are given. the aha users from the db and the admin.
#admin still have an unsecured password
providers:
chain_provider:
providers: [in_memory, user_db]
in_memory:
users:
admin: { password: 2, roles: ROLE_ADMIN }
#for aha-users there is a custom table. the login procedure is getting the data from the entity
user_db:
entity: { class: BackendAccountBundleEntityUser, property: email }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/(en|de)/secured/login
#security: false
anonymous: ~
secured_area:
pattern: ^/(en|de)/secured/
anonymous: ~
http_basic:
realm: "Secured Area"
form_login:
check_path: security_check
login_path: backend_account_login
use_referer: false
default_target_path: backend_secured_account_index
#target_path_parameter: frontend_account_my_account
logout:
path: /de/secured/logout
target: /de/
#default_target_path: frontend_account_login
#anonymous: ~
#the access of user e.g. admin and aha users are given below
access_control:
- { path: ^/*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(en|de)/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(en|de)/*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(en|de)/secured/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(en|de)/secured/, roles: [ROLE_AHA_USER, ROLE_ADMIN] }
- { path: ^/(en|de)/secured/account/admin/register/, roles: ROLE_ADMIN }
根据2.0.25 Symfony依赖注入和文档参考(见下文)的建议,您应该将check_path定义为绝对url,而不是路由名称。(例如:/en/安全/login_check)
2.0的安全参考(已弃用):http://symfony.com/doc/2.0/reference/configuration/security.html the-login-form-and-process
电流:http://symfony.com/doc/current/reference/configuration/security.html#the-login-form-and-process(后者说明你可以使用路由名。)