mercredi 15 avril 2015

Spring Security CSRF meta tag Dom Selection

I'm using Spring Security in my application and our POST calls need append a CSRF token to all request headers which are posted to our server side.



Looking at Spring Security blog, I've found the following solution in jquery.


Code:



var token = $("meta[name='_csrf']").attr("content");

var header = $("meta[name='_csrf_header']").attr("content");



The meta tags in my single page app are:


Code:



<meta name="_csrf_parameter" content="_csrf" />

<meta name="_csrf_header" content="X-CSRF-TOKEN" />

<meta name="_csrf" content="......." />



How can I achieve the selection like what was done in jquery. I'll grab the values and add them to my overrides file so that each request has the token added in the header.



I've tried the following but getting "Error parsing selector. Parsing failed at "['_csrf']"


Code:



var value = Ext.dom.Query.select("meta['_csrf']");


Any help would be greatly appreciated





Spring Security CSRF meta tag Dom Selection

Aucun commentaire:

Enregistrer un commentaire