I
I
Irek Sitdikov2015-07-13 13:19:10
CSRF
Irek Sitdikov, 2015-07-13 13:19:10

How to disable csrf verification for post requests from third party resources in Laravel 5?

I have a task to implement a POST-reception on a site from 1C.
Opened a route to accept requests. In middleware/VerifyCsrfToken.php turned off verification for the required urls:

private $openRoutes = ['xml/desk/1', 'xml/desk/2'];
public function handle($request, Closure $next){
        foreach($this->openRoutes as $route) {

            if ($request->is($route)) {
                return $next($request);
            }

        }
        return parent::handle($request, $next);
}

But still, a similar response comes in 1C:
TokenMismatchException in project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php line 46

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2015-07-13
@AmdY

It's most likely a misunderstanding here. Check if your handler enters, if the check works there, perhaps the original middleware is connected in another place, etc.
Put a break on the 46th line and you will understand everything from the trace.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question