O
O
Oleg Pravdin2018-07-20 16:28:55
Laravel
Oleg Pravdin, 2018-07-20 16:28:55

Where to structure access control in Laravel?

Hello. There is a category model and notes in Laravel. Roles are attached to standard authorization (each role has a numerical value of its weight, for example, user 100, editor 1000, administrator 9999). Where to architecturally attribute the tolerance check upon receipt of the next request. The permission can be either explicit (the request is allowed / denied in principle, for example, the user cannot create a category, unlike the admin), or limited (for example, the editor cannot explicitly delete the category if it contains an article or subcategory, but the admin can). What is the best way to implement this?
I was thinking of splitting the check into 2 parts. The first through middlware (as in the documentation) checks the weight of the user's role for a specific operation (i.e. Auth::user()->role->weight >= 1000 is the editor's permission and higher), and specific checks like deletion restrictions are carried out directly in the controller.
Thank you in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Camaro67, 2018-07-20
@Camaro67

https://github.com/dlnsk/h-rbac ( article on Habré)
https://github.com/Zizaco/entrust
https://github.com/cartalyst/sentinel
https://github.com/romanbican/ roles
https://github.com/JosephSilber/bouncer
https://github.com/santigarcor/laratrust
And smoke this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question