RBAC next steps

Hi,

I’ve recently started with my first Yii project, which should become a community site. I quickly stumbled upon the Yii skeleton app and the SRBAC module. Adopted most of the skeleton user-related code to build the basic user stuff like login, logout, register, edit, manage and lost-password. These things now work. Then added and installed the SRBAC module. I can now also assign roles, tasks and operations to users. This is all nicely being written to those three database tables.

I however find the RBAC documentation in the definitive guide incomprehensible for me as newbie (at Yii, object-oriented php coding and MVC frameworks). It also seems incomplete to me. Searching Google and this forum so far hasn’t helped me solve it.

I understand I can use accessRules and/or Yii::app()->user->checkAccess() to check if a user has the proper credentials. Here’s what I don’t understand yet:

  • How do I assign roles/tasks/operations to a user at login when using the database for storing the RBAC information? Or is there a function within the SRBAC module that can do this for me?

  • Do I even have to assign it at login or can I just use checkAccess() and Yii will consult the proper tables automatically?

  • Do I have to write a whole script with loops to read the tables and recreate all the roles, tasks and operations that I’ve defined in the database to resemble the script in the definitive guide? If so, does someone have some example code to put me on the right track and help save some time?

Thanks!

bump

  1. If you are using the srbac module you only have to assign roles to user with the provided GUI in the module

  2. You only have to check if the user has access in your controller’s actions

  3. The script in the guide is for the PhpAuthManager. The DbAuthManager does not require this. You only have to create the items in the srbac GUI , assign operations/tasks/roles and check for access in the controllers.

I am currently implementing an automatic creation / assignments and checking of auth items by parsing the controllers script, check the Srbac thread http://www.yiiframework.com/forum/index.php?/topic/2994-extension-srbac-web-interface-for-the-administration-of-rbac/page__pid__24853__st__80&#entry24853 if you have more questions.

Thanks! got it all working now. On to the next challenge!

Oh and have I already said that Yii (and the SRBAC module) is a great framework AND has a really friendly community? I gave Symfony a shot before… Found the software to be too big, complicated and strict. The documentation was limited, outdated and unclear and the community much more closed. In my experience Yii is far more starter-friendly. Great! Keep up the good work!

Symfony is complicated but has very good documentation that’s why I had preferred it but Yii is a lot better. With good documentation and community, Yii is simpler and easy to remember framework. Now Yii is my preferred framework.

Thanks Yii team.