开发者

Level based acces control in ruby on rails

I want to implement a level based access control in my ruby on rails application. Like there a user at lower level will not be able to access data of its parent. Example

  Main Admin
  |
  |___ Sub Admin1
  |      |
  |      |
  |      |___ SA1_USER1
  |      |
  |      |___ SA1_USER2
  |
  |
  |
  |___ Sub Admin2
         |
         |___ SA2_USER1
         |      |     
         |      |__End_user1
         |      |__End_user2
         |
         |___ SA2_USER2

In the structure above say every user can create a record. But records will be view开发者_Go百科ed according to the hierarchy. Like Main Admin will be able to access all records, Sub Admin1 can access records created by self, SA1_user1 and sa1_user2 and so on..

Is there any good plug in to implement this in ruby on rails?

Thanks, PraWin.


I don't know of a plugin, but it wouldn't be all that hard to write yourself. You would just have to have an owner_id on each created record you want people to access, and each user would have a parent user, then you would write up a model method for user.is_ancestor_of? record.owner to check anytime a user attempts to access a record.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜