Что такое CSRF атака и как она обрабатывается в фреймворке Laravel доступно описано тут. Долго искалразжеваннойхорошо описанной темы как же на уровне Laravel происходит обработка.
В двух словах:
Using the CSRF token
Laravel already prevents itself from CSRF attacks by default whether you do anything or not. So, if you make a request without adding the CSRF Token, the request will be rejected.
If you go to the file
app/Http/Kernel.php you will see the VerifyCsrfToken middleware defined:<?php [...] class Kernel extends HttpKernel { [...] protected $middlewareGroups = [ 'web' => [ [...] \App\Http\Middleware\VerifyCsrfToken::class, [...] ], [...] ]; [...] }
If you go to the
app/Providers/RouteServiceProvider.php file you’ll see that in the mapWebRoutes() method the web group middleware is added to all web routes. This means that by default Laravel will check for a valid CSRF token using the VerifyCsrfToken class.
Комментарии
Отправить комментарий