A
A
Alexander2022-03-30 15:01:59
User identification
Alexander, 2022-03-30 15:01:59

How to organize authorization in Laravel?

Tell me, if you use middleware in routes, will this step be enough for security or is it worth checking authorization also through an observer? PS I'm just learning =)
Route::get()->middleware('auth');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKEPTIC, 2022-03-30
@pro100chel

Yes, everything is fine.
The main thing is that the logic in this middleware is correct and do not forget to hang this middleware on the routes where this authorization is needed.
The logic itself is simple - checking the session key / token or something else. If there is a division into roles / rights, then check for the sufficiency of the role for the action being performed. All.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question