Building a generic OO ACL using Doctrine

2019-02-24 07:55发布

I'm looking to design a doctrine-backed ACL system for my own use, although I'm struggling with some of the initial design considerations.

Right now I'm looking at making it based on classes and unique identifiers, storing them in a table as such:

Table: ACL
    ResourceClass
    ResourceKey
    RoleClass
    RoleKey
    Permission

Obviously this is going to demand that I introspect on classes that are being queried to derive the correct ResourceClass values.

I'm wondering if this approach has been done before or if anyone has some advice with doing it in a bettery way. Other things like recursive relationships between Roles also confound me as I'm not sure how to recursively query to build and ACL for a Resource.

I'm not a huge fan of Zend ACL, so please no suggestions for it - I am aware of it!

Further clarifications will be made to this question as people weigh in, so please bear with me! This question itself may require a few iterations! ;)

1条回答
孤傲高冷的网名
2楼-- · 2019-02-24 08:44

I use NestedSet for storing the ACL hierarchy and cache to speed things up.

Doctrine ORM for PHP - NestedSet

Here is a post which may be useful too:

Zend_Acl part 3: creating and storing dynamic ACLs | CodeUtopia - The blog of Jani Hartikainen

(take a look at the two previous parts as well).

查看更多
登录 后发表回答