ScoRpion
ScoRpion

Reputation: 11474

How To Work With User Authentication, Permissions And User Roles With Symfony2?

I learned Symfony2 recently and I have created a small application with it. It works fine till now.

I have created a user module where i register a user. and then that user can login to access the application. I am using the SESSION as well to carry the user object from one page to another. I have not yet done any sort of authentication that will check if the user session is active and that is the reason when I enter a url manually it takes me to the page without checking if i have logged in or not.

Also I want to have different user with different access roles. i,e I don't want to give all access to all users. Some users should have limited access.

Can anyone tell me :

  1. what is the best way to do this.
  2. How can i redirect every url entered, to login page unless user is logged in
  3. I would also like to have some tutorials regarding the same.

Upvotes: 1

Views: 3493

Answers (1)

Guillaume Flandre
Guillaume Flandre

Reputation: 8980

The FOSUserBundle is very useful for everything related to user management, and it's very popular too, you should look into it: https://github.com/FriendsOfSymfony/FOSUserBundle

Check-out the documentation here: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md

Upvotes: 2

Related Questions