我正在尝试在 Symfony2 记住我登录中实现功能。
我有这个配置文件security.yml
security:
firewalls:
frontend:
pattern: ^/
anonymous: ~
form_login:
login_path: /login
check_path: /login_check
default_target_path: /index
success_handler: authentication_handler
logout:
path: /logout
target: /login
success_handler: authentication_handler
security: true
remember_me:
key: "%secret%"
lifetime: 120
path: /
access_denied_handler: accessdenied_handler
#primero deben de ir los usuarios anonimos si no se entra en loop redirect
access_control:
- { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/js, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, roles: ROLE_A }
- { path: ^/nuevoinforme, roles: ROLE_M }
- { path: ^/, roles: IS_AUTHENTICATED_REMEMBERED }
providers:
user_db:
entity: { class: mio\mioBundle\Entity\Empleado, property: username }
role_hierarchy:
ROLE_M: ROLE_U
ROLE_A: ROLE_U
encoders:
mio\mioBundle\Entity\Empleado: { algorithm: sha1 }
Symfony\Component\Security\Core\User\User: plaintext
当我登录时,cookie 已正确存储在客户端上。但是,在 120 秒后,在尝试访问另一个 URL 时,它仍然认为客户端已登录,而我希望它会被注销,因此我希望客户端被重定向到/login
.
我该如何解决这个问题?