Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

Compatibility with route caching #719

Open profxp opened 7 years ago

profxp commented 7 years ago

Hi there,

I use extensively your excellent plugin. Now I would like to to do route caching https://laravel.com/docs/5.1/controllers#route-caching but after doing so, it seems that the route cache completely ignores the Entrust rules set-up in the routes file. Is there a way to make Entrust compatible with route caching?

Thanks.

profxp commented 7 years ago

No answer? :-(

derekmd commented 7 years ago

https://github.com/Zizaco/entrust/blob/master/src/Entrust/Entrust.php#L92 That functionality uses Route::filter() and Route::when() which rely on router events not triggering when caching is enabled.

Keep in mind those two functions were deprecated in Laravel 5.2 https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0 so you should think about instead implementing your ACL using middleware where $request->route() has the metadata required to assert whether a user has access.

profxp commented 7 years ago

Many thanks for your answer. I am not sure to understand: if I update my website to 5.2 then what will be the syntax I should use in order to have Entrust compatible with Laravel route caching.

nonlocalize commented 7 years ago

I have no experience using this package, but give this a go: http://lmgtfy.com/?q=laravel+5.2+entrust+middleware.

profxp commented 7 years ago

Hi @derekmd you did not answer my previous question. If I update my website to 5.2 then what would be the syntax I should use in order to have Entrust compatible with Laravel route caching?

Many thanks.

reganjohnson commented 7 years ago

🤦‍♂️