Results 1 to 3 of 3

Thread: Spring Security CSRF meta tag Dom Selection

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Location
    New York
    Posts
    188
    Answers
    2

    Default Answered: 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

  2. It'd be the same as the selector for jQuery wouldn't it? You've dropped the 'name=' part in your Ext version.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    It'd be the same as the selector for jQuery wouldn't it? You've dropped the 'name=' part in your Ext version.

  4. #3
    Sencha User
    Join Date
    Dec 2008
    Location
    New York
    Posts
    188
    Answers
    2

    Default

    Quote Originally Posted by skirtle View Post
    It'd be the same as the selector for jQuery wouldn't it? You've dropped the 'name=' part in your Ext version.
    Hi Skirtle,

    Thanks for replying. I was trying different combinations yesterday. Maybe it was just a long day. Thanks

    Code:
    Ext.dom.Query.select("meta[name='_csrf']");

Similar Threads

  1. Replies: 1
    Last Post: 5 May 2014, 8:38 AM
  2. Spring Security (Acegi) and ExtJS
    By cornflakes in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 15 Jul 2011, 12:33 AM
  3. ExtJS and Spring Security 3
    By Shining77 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 8 Feb 2011, 4:26 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •