Uses Symfony-like voters to check permissions
Install:
composer require onix-systems-php/hyperf-policyTo make it works, you need:
-
create policy class based on
OnixSystemsPHP\HyperfPolicy\Policy\AbstractPolicy -
add
OnixSystemsPHP\HyperfPolicy\Annotation\Policyannotation to the policy and setup it's priority (higher number executes first) -
specify what classes\objects and actions your policy will work with
-
specify vote logic and return one of the values:
PolicyVote::ACCESS_DENIED- stop execution and throw exception specified ingetExceptionmethodPolicyVote::ACCESS_GRANTED- allow current action and skip all following policiesPolicyVote::ACCESS_ABSTAIN- go to next policy, allow action if no policies left to check
-
create data specifier class based on
OnixSystemsPHP\HyperfPolicy\Policy\AbstractDataSpecifier -
add
OnixSystemsPHP\HyperfPolicy\Annotation\DataSpecifierannotation to the specifier and setup it's priority (higher number executes first) -
specify what repositories and actions your specifier will work with