machuga/authority

Super User (or 'Super Admin Role')

deviarte opened this issue · 3 comments

We are currently using this package in an internal application for our company.
Everything works as expected!

But we can't handle Super Users (or a Super Admin Role) seamlessly.
What we currently do is load all possible ACL actions and give the super admin ALLOW for everything.

But this is kind of wasteful use of resources since the application is designed to load ACL actions on a per request basis.

Example: If /contacts/* is being requested, fetch all ACL actions (from file) and all permissions (from db) just for the contacts module.

We currently have around 300 ACL actions and 20 roles, this can add up really quick if a super admin is detected, since we need to load all actions.

How can this be handled "better" ?

Note: I am happy to submit a pull request if needed, but would love to hear your ideas first.

Note 2: I am aware of $authority->allow(ALIAS, 'all');
But what i really need is: $authority->allow('all', 'all');
Since read,create,update,delete is not enough, we have tons of other uses like: send, pull, fetch etc.

@deviarte so allow('all', 'all') doesn't currently work? If not I believe this is an oversight on my part.

Nope, only the second 'all' works. (resources)

@deviarte You can replace the line 92 of Rule.php by this one:

        return $this->action === 'manage' || in_array($this->action,$action);

Or you can test this behavior with my Authority-Controller package who patch Authority.
Then you can do:

$authority->allow('manage', 'all');