问题是登录表单没有捕获javascript
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: sitio123
lifetime: 604800 # 7 * 24 * 3600 = 604.800 = 1 semana
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: ^/, roles: ROLE_U }
- { path: ^/admin, roles: ROLE_A }
providers:
chain_provider:
providers: [in_memory, user_db]
in_memory:
users:
foo: { password: test, roles: 'ROLE_A' }
foo1: { password: test1, roles: 'ROLE_U' }
user_db:
entity: { class: mio\mioBundle\Entity\Empleado, property: username }
role_hierarchy:
ROLE_A: ROLE_U
encoders:
mio\mioBundle\Entity\Empleado: { algorithm: sha1 }
Symfony\Component\Security\Core\User\User: plaintext
删除该行
- { path: ^/, roles: ROLE_U }
正常工作。感谢。
答案 0 :(得分:1)
尝试添加另一行:
access_control:
...
- { path: ^/js/*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
...
现在没有想要记录的角色ROLE_U的用户有权访问JS!
我认为你还需要为图像和CSS做到这一点!