ruby on Rails 中基于级别的访问控制
我想在 ruby on Rails 应用程序中实现基于级别的访问控制。 就像那里的较低级别的用户将无法访问其父级的数据。 示例
Main Admin | |___ Sub Admin1 | | | | | |___ SA1_USER1 | | | |___ SA1_USER2 | | | |___ Sub Admin2 | |___ SA2_USER1 | | | |__End_user1 | |__End_user2 | |___ SA2_USER2
在上面的结构中,假设每个用户都可以创建一条记录。但记录将根据层次结构进行查看。 就像主管理员将能够访问所有记录一样,子管理员1可以访问自己创建的记录,SA1_user1和sa1_user2等等。
是否有任何好的插件可以在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 viewed 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道插件,但自己编写并不难。您只需要在您希望人们访问的每个创建的记录上有一个owner_id,并且每个用户都有一个父用户,然后您将为 user.is_ancestor_of 编写一个模型方法? record.owner 在用户尝试访问记录时进行检查。
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.