A special kind of role may be the "role of the owner." This role applies when you own an object. Idea for implementation in client code:
if ($owner->isAllowed('view', $image) { do stuff }
RBAC system:
$this->roles->add(new OwnerRole($user); }
$roles = $this->getRoles($user);
foreach ($roles as $role) {
if ($role->isAllowed($user, $action, $object)) { return true; }
}
This means that the owner role should be able to verify who owns the object:
class OwnerRole implements Role
{
public function __construct(OwernChecker $ownerChecker) {
$this->owerChecker = $ownerChecker;
}
public function isAllowed(User $user, $action, $object) {
if ($this->ownerChecker->userOwnsObject($user, $object)) etc
}
}
The ownerChecker object may be given mappings of how to verify that the user owns the object.
The following are recommended data:
http://www.xaprb.com/blog/2006/08/16/how-to-build-role-based-access-control-in-sql/
http://www.sqlrecipes.com / database_design / fine_grained_role_based_access_control_rbac_system-3 /
source
share