Hi all,I've just started with Roda a few days ago and I really like it. However, I've hit a wall today with implementing csrf. I'm using Mastering Roda and this tutorial as guides and I've taken the roda-sequel-stack as the starter package.
Hi,what about with ajax requests?I have the token in layout.erb like so:<meta name="csrf-token" content="<%= csrf_token %>">And in my script:var csrfToken = $('meta[name="csrf-token"]').attr('content');$.ajax({url: '/modify_entity',type: 'POST',data: params,headers: {'X-CSRF-Token': csrfToken},And I still get the bad request due to an invalid token.Any idea what is incorrect?
--
You received this message because you are subscribed to the Google Groups "Roda" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-roda+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-roda/CADGZSSeuw5GPVW6epdX9yKyTpx1tTr9vMkfZ%2BXec8Q2tksHUPw%40mail.gmail.com.
I would actually opt for highest security. So I'd remove the meta tag, but what is then the correct reference in the ajax request?
I've found the bug that prevented csrf being in the request header and I see it in the console. But I still get bad request due to an invalid security token.
četrtek, 13. junij 2024 ob 22:14:57 UTC+2 je oseba jeremy...@gmail.com napisala:On Thu, Jun 13, 2024 at 1:05 PM Sebastjan Hribar <sebastja...@gmail.com> wrote:I would actually opt for highest security. So I'd remove the meta tag, but what is then the correct reference in the ajax request?You should be able to get an appropriate token via:csrf_token('/modify_entity')Thanks,Jeremy
--
You received this message because you are subscribed to the Google Groups "Roda" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-roda+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-roda/b3ec5c45-ef91-4fff-bb7c-ffe3191fa3d9n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-roda/CADGZSSdSJzrAfNAmaC8wZ%2B_j1YKM%2Bny66SYu44BK6RaVO_txvA%40mail.gmail.com.