是否有任何库/解决方案提供对资源的部分访问?这种权限控制是如何被调用的?部分访问控制PHP
大多数ACL库允许/拒绝完全行动:
user.create user.update user.show
但是如果有应该是一个 “局部” 的权限。 喜欢的东西:
- 你只能看到活跃用户与角色客人或主持人。
- 你被允许与角色设计师但只有他电话和邮件编辑的用户。
第一个例子可以是这样的:
权限:
user.show
特权:
status => active && role => guest || moderator
和第二:
权限:
user.edit
特权:
editable => phone, mail
更新:
为了使我的问题更清楚,我已经加入此使用示例,以显示如何(在我的想法中)它可能看起来像。
// global access
if($user->can('user.show')){
// get the privileges provided by the permissions
$filter = $user->getPrivilegesFor('user.show');
// use the privileges to filter the (database)query
// (using the example above the filter should restrict to active guests and moderators)
$result = $repo->getUsers($filter);
}else{
// access denied
}
// use the result to fill the view
似乎我没有举一个好例子。我的问题不是为用户提供角色,我正在寻找一个允许采用更多差异化方法的权限库,而不是仅允许或拒绝某个操作。在我的示例中,有一个权限允许显示活动并属于角色来宾或主持人的用户。可能有另一个允许看到不活跃的女性用户等的许可。 – user3333137