Is there a way to exclude a route from CSRF protection from a package in Laravel 5?

I know the $exceptmiddleware property VerifyCsrfToken( app/Http/Middleware/VerifyCsrfToken.php), but I'm looking for a way to make something similar from my package (so users who install it do not need to change them VerifyCsrfToken.phpfor my work route).

I can define the routes in my package, but I do not know how to exclude from them (or more) them from the middleware by default. I tried expanding Illuminate\Foundation\Http\Middleware\VerifyCsrfTokenon my own package with no luck.

+4
source share
2 answers

, , , , , :

    <?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'stripe/*',
    ];
}
0

, . , $middleware app/Http/Kernel.php.

. , .

, VerifyCsrfToken.

$except VerifyCsrfToken Service Container, . , ​​ . , .

0

Source: https://habr.com/ru/post/1611987/


All Articles