Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get laravel CSRF token from outside laravel

I need to post a search form from classic asp to a laravel route. I can get the csrf token from the cookie, if there is one and put it into the form, but I don't know what to do if there is no csrf cookie?

Should I open laravel route that returns new csrf token or is that a security risk?

Is the only other option to remove the route I need to post to from csrf validation?

like image 509
iKode Avatar asked Nov 03 '15 18:11

iKode


Video Answer


1 Answers

You can disable CSRF protection for specific route in VerifyCsrfToken middleware, you will find $protected $except array you can add the routes that will not be checked for CSRF Token

/**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        // for example
        "form/route"
    ];
like image 118
Mohammed Omer Avatar answered Sep 24 '22 20:09

Mohammed Omer