-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PolicyRuleManager suggestion #45
Comments
Hello ! In fact, what you suggest was planned already in the library. As you can see, the $object variable can be null in the enforce function and I thought I already made possible to just check the user attributes in this case. But reviewing the code now I can see that this feature does not seem to be available for now. To be more specific what I planned was to configure multiple resources for one rule. The library would check the class of the given resource, and know which attributes are to be checked to enforce the rule. If none is given, only the user attributes shall be checked. The same design can be applied to the user attributes, with different user classes configured for one rule. |
OK, but it's hard for me to imagine the use case for this:) Generally user is a currently logged in user, it can be only one at the same time... |
In some applications, the User class is not the same for two distincts users. In my case, I have for exemple a trade account, using a Let's imagine that I have a rule to buy something. For a Member, I must check that he has a payment method in his attributes, whereas I know that the Merchant has already it. In this case, the checks won't be the same depending on the User class. |
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:
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:
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
The text was updated successfully, but these errors were encountered: