是否有任何庫/解決方案提供對資源的部分訪問?這種權限控制是如何被調用的?部分訪問控制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