dougaimian1143 2015-03-07 21:34
浏览 39
已采纳

Symfony2中的嵌套授权支持

A system has nested resources. For example

Farm HasMany Sectors

An example object relation will be like below

farm1 => [sector1]
farm2 => [sector2, sector3]

Now say, user1 has read,write permission on farm1.

user1 Has(read,write) on farm1

I need the system to automatically use the access for all the nested resources of farm1, in this case sector1.

In other words, something like user1.hasWritePermisson(sector1) should return true, though the ACL is actually stored with farm1. I need this even to work on the nested resources of sector and so on.

A straightforward solution would probably be to copy the access to all of the children objects of farm1 at the updating its acl. But I believe this would be a really inefficient one if farm1 contains thousands of sectors.

What would be the best way to achieve this in symfony2?

  • 写回答

1条回答 默认 最新

  • duanduan8439 2015-03-07 21:55
    关注

    First of all. I think your question has nothing to do with SF2. In my opinion, you should create a efficient database which helps you to do the task. The rest is only a few queries away.

    As I understand, it will be 3 major objects: User, Farm and Sector.

    User could be in many Farms and Farms could be seen/wrote by many users

    A Farm has many sectors, but a sector can only be in one farm

    That being clarified, you will also need to declare the permissions for every user has in a farm. But, this will be declared in the many-to-many relationship with two relationship properties (read, write).

    Once everything well designed, you should be able to create queries that satisfy your needs.

    I know it's hard to understand because I'm talking in abstract, but let me know if you don't understand and I will draw you a scheme.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器