-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Please take a look at PolicyRuleManager::getRule() method.
I suppose it will be very usefull in some cases to make 2 steps authorization. Especially when using frameworks:
- We need to check if user can acces this action at all. If not, we just stop the code and dont try to get the object:
$abac->enforce('blabla', $user);- Only after that we want to perform query to database to find an object and check acces to the object:
$abac->enforce('blabla', $user, $object);This can be very usefull when db query (or 3rd party service query) is heavy and takes much time.
But in current implementation it is not possible with a single rule. The library will always try to check $object even if it wasnt passed to enforce() method.
So, I suggest to add a check to the PolicyRuleManager::getRule() method like this:
foreach ($this->processRuleAttributes($rule['attributes'], $user, $resource) as $pra) {
if(!$resource && $pra->getAttribute()->getType() == 'resource') {
continue;
}
$Policy->addPolicyRuleAttribute($pra);
}Maybe there can be more pretty way to do this. So what do you think? Another option is to add a method to Abac class
$abac->enforceUserOnly('blabla', $user);// or somth like thisMetadata
Metadata
Assignees
Labels
No labels