Reputation:
I'm using FosUserBundle for my Symfony2 project. I've added a rule for the custom ROLE_VALIDE
to restrict the paths like /user
. It works for the users having this role.
The problem is that I also want the admins to be able to access this path.
I've tested with both roles ROLE_ADMIN
and ROLE_ADMIN + ROLE_VALIDE
but I have the 403 error page.
Is there a way to add more than one role in the access_control
?
access_control:
- { path: ^/admin, role: ROLE_ADMIN }
- { path: ^/user, role: ROLE_VALIDE }
Upvotes: 1
Views: 1465
Reputation: 30975
What about role hierarchy in your security.yml ?
doc : http://symfony.com/doc/current/book/security.html#hierarchical-roles
role_hierarchy:
ROLE_USER: [ROLE_USER]
ROLE_VALIDE: [ROLE_USER, ROLE_VALIDE]
ROLE_ADMIN: [ROLE_USER, ROLE_VALIDE, ROLE_ADMIN]
With this, if route is waiting for ROLE_VALIDE
, ROLE_ADMIN
is ok because is has ROLE_VALIDE
inside it.
Upvotes: 1