rstaib / jquery-bootgrid

Nice, sleek and intuitive. A grid control especially designed for bootstrap.
http://www.jquery-bootgrid.com
MIT License
972 stars 364 forks source link

CodeIgniter and CSRF #373

Open Bliksempie opened 6 years ago

Bliksempie commented 6 years ago

I have searched everywhere, and there does not seem to be a way to get the listing to work with CSRF protection enabled in CodeIgniter. It shows "No results found" but when I disabled CSRF in CodeIgniter, listings work again.

I have tried to add the CSRF fields, as per CodeIgniter's requirements, into the following config sections of BootGrid:

Entry looks like this:

csrf_test_name: "24be586ffee23e859527a847a36cc99c",

Looking at the source, the search field does not have a form tag, and thus, I suspect that is why these two items I have added does not do anything, as those CSRF token data needs to be added as a hidden field inside a form.

Please can this be resolved? I really do not want to disable CSRF security in favour of a grid tool :-(

Kind regards,

Blix

bellwood commented 6 years ago

You can add the following to your jquery-bootgrid object definition (how I use it for Laravel)

post: function ()
{
    return {
    _token:"{{ csrf_token() }}",
    };
},
Bliksempie commented 6 years ago

Thank you, bellwood! I will check it out, and provide feedback to close if it works :-)