ruby on Rails 中基于级别的访问控制

发布于 2024-10-03 11:21:17 字数 548 浏览 0 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不是你的备胎 2024-10-10 11:21:17

我不知道插件,但自己编写并不难。您只需要在您希望人们访问的每个创建的记录上有一个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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文