Reputation: 3391
I'm trying to study the FOSUserBundle. I follow the steps of their documentation (link) and I successfully created a login form and registration. Now, I'm creating another controller name TodoController and I want to secure that TodoController. It needs the user to login first before they show the page of todo. How can I secure the TodoController?
Upvotes: 0
Views: 22
Reputation: 1000
FOSUserBundle only extend the Symfony security layer, but all other Symfony security stuff remains the same, so you can use the default access control from symfony security
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
You will find it mentioned in the link you provided, but you can read more about it here http://symfony.com/doc/current/security/access_control.html
Or if you want something more flexible and more powerful you can take a look at JMSSecurityExtraBundle http://jmsyst.com/bundles/JMSSecurityExtraBundle/1.2/annotations
Hope this helps,
Alexandru Cosoi
Upvotes: 1