-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Global administrator, allowing all permissions #637
Comments
Intercept the created event in the Permission model and attach the created permission to the superadmin role. |
I don't think this quite suffices as a proper solution to this problem. It sounds more like a workaround than a proper solution. (Thank you for your response anyway, I appreciate the effort) |
Without modifing Laratrust behaviour there are only 2 ways to do what you need. The first one is to keep the SuperAdmin role permissions in sync with all the available permissions (see above for the implementation) The second one is to add a check for the SuperAdmin role everytime you check for permissions (ie. if the user has this permission OR he has the SuperAdmin role). Otherwise, you have to change the Laratrust behaviour to check for the single permission OR check for the SuperAdmin role. From my point of view, the first solution is the easiest and cleanest of all of them. |
I am not entirely sure if this would work, but after some digging, perhaps it'd be possible to override the Wouldn't that hide away the trait's method for my own implementation? Since class methods take precedence over trait methods. Correct me if I'm wrong of course, but isn't that a possible solution? |
How I've made it in the past is by defining one permission that only super admins have and in side the policies i check if the user has that permission or the actually required permission. or by simply adding all the permissions to the admin. |
even though it's not exactly the solution I was looking for, it is a better solution than what was proposed before, in my honest opinion. Thank you both for your help. I'll propose this change internally. |
Hi!
I am currently working on a project that uses Laratrust, and I was wondering if it was possible to define a role that automatically gets all allowed permissions?
Currently our system solves this by having a copy of every permission prefixed with
superadmin-
. I'd like to change that to a simple boolean on a role that when set totrue
will return success on any permission check.Is something like this possible natively with Laratrust? I had considered overriding some methods on the
LaratrustUserTrait
trait, but quickly figured out that that might not be the best way?Thank you in advance!
(This project uses laratrust 6.1.0)
The text was updated successfully, but these errors were encountered: