csrf-protection

How to setup CSRF in JavaScript for laravel?

不想你离开。 提交于 2019-12-08 09:27:27
问题 I only use JavaScript. And i know jQuery will set's the CSRF by, $(function() { $.ajaxSetup({ headers: { 'X-CSRF-Token': $('meta[name="_token"]').attr('content') } }); }); But how could i use "CSRF-Token" in JavaScript ? Is there any possibilities for common setup for all Ajax Call ? 回答1: To use csrf token common for all the ajax calls you have put following code in your master layout blade file. In layout header: <meta name="csrf-token" content="{{ csrf_token() }}" /> In your layout footer:

CSRF Token Needed?

一曲冷凌霜 提交于 2019-12-08 08:32:27
问题 Ok, still trying to wrap my head around what they are, and needed for ..believe me I've read plenty on it and think I understand but I probably don't ... The closest I can get is that they're definitely needed when you have log-in pages in any form on your site ... My question is when you have basic contact form and/or fill-in form for any reason ... do you need CSRF tokens for those pages? 回答1: CSRF tokens are not 'definitely needed' (as in, forms will work without them) but they are an

protect form hijacking hack

左心房为你撑大大i 提交于 2019-12-08 08:15:23
问题 Yes hello today I discovered a hack for my site. When you write a msg on a users wall (in my communitysite) it runs a ajax call, to insert the msg to the db and will then on success slide down and show it. Works fine with no problem. So I was rethinking alittle, I am using POST methods for this and if it was GET method you could easily do ?msg=haxmsg&usr=12345679. But what could you do to come around the POST method? I made a new html document, made a form and on action i set "site.com

Codeigniter with jqGrid: use csrf_token

牧云@^-^@ 提交于 2019-12-08 06:13:09
问题 If in config file I set csrf_token to false and everything works. However when csrf_token is true , my grid can only get data from database but not update or anything else. I'm looking through the posts on this site about Сodeigniter+jqGrid but still haven't understand what should I do. I can get the value of csrf_token but where it should be included? var lastsel; var addl_params = { ci_csrf: $.cookie('ci_csrf_token') }; $("#grid").jqGrid({ url:'url to script', datatype: "json", mtype: 'GET'

Add CSRF token to all the FORM submissions

纵饮孤独 提交于 2019-12-08 05:48:20
问题 I recently enabled CSRF protection in my web Application. There are around 100+ JSP pages containing FORM submission. What is the best way adding CSRF token : <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> such that all the form submission will have this form data. I don't want to add this parameter to every individual FORM submit. 回答1: So I've finally found a working solution. Basically I create a custom FormRenderer like this : import com.sun.faces.renderkit

RoR + Devise: CSRF token changes at every request

≯℡__Kan透↙ 提交于 2019-12-07 22:48:06
问题 I am using Devise to handle authentification in a web application, and I set it up to work with Ajax as explained on this blog post. It works fine, I can sign in and out. However, there is an anomaly: the CSRF token is regenerated at every request. This happens whether the user is signed in or not, and even if the request is a GET, although I keep reading everywhere that the token should not change during a session. This forces me to add a mechanism to update the token on the client, since it

Add CSRF token to all the FORM submissions

与世无争的帅哥 提交于 2019-12-07 02:21:29
I recently enabled CSRF protection in my web Application. There are around 100+ JSP pages containing FORM submission. What is the best way adding CSRF token : <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> such that all the form submission will have this form data. I don't want to add this parameter to every individual FORM submit. So I've finally found a working solution. Basically I create a custom FormRenderer like this : import com.sun.faces.renderkit.html_basic.FormRenderer; import javax.el.ELContext; import javax.el.ExpressionFactory; import javax.faces

How can I use ring anti-forgery / CSRF token with latest version ring/compojure?

血红的双手。 提交于 2019-12-07 01:27:25
问题 I copied some old code that was working in compojure 1.1.18 and other old libs, but using the latest versions I can't get it to work. Here's my minimal example code copied from the minimal example here to demonstrate that with latest ring and compojure libraries, I get an error when I send an http POST , even with the header set. lein ring server to start it, then do curl -X GET --cookie-jar cookies "http://localhost:3000/" which results in something like this: {"csrf-token":"7JnNbzx8BNG

How to use token between action chains, properly?

为君一笑 提交于 2019-12-06 17:26:15
I have an action which I should protect it from CSRF attack. I have used Strut's tokenSession Interceptor to achieve this. <action name="showBranchSelection" class="action.Request.BranchSelectionAction" method="showBranchSelection"> <interceptor-ref name="tokenSession" /> <interceptor-ref name="basicStack" /> <result name="success"> /jsp/customer/request/branchSelection.jsp </result> </action> and works great where this action has been called directly from jsp. <s:form id="frmRequestShowBranchSelection" action="../../showBranchSelection" method="post" theme="simple" onsubmit="return false;">

RoR + Devise: CSRF token changes at every request

被刻印的时光 ゝ 提交于 2019-12-06 14:22:22
I am using Devise to handle authentification in a web application, and I set it up to work with Ajax as explained on this blog post . It works fine, I can sign in and out. However, there is an anomaly: the CSRF token is regenerated at every request. This happens whether the user is signed in or not, and even if the request is a GET, although I keep reading everywhere that the token should not change during a session. This forces me to add a mechanism to update the token on the client, since it is not done automatically because I use Ajax. Could someone tell me if this has somehow become the