November 2017
Intermediate to advanced
542 pages
14h 24m
English
If you are using JSON, then it is not possible to submit the CSRF token within an HTTP parameter. Instead, you can submit the token within a HTTP header. A typical pattern would be to include the CSRF token within your <meta> HTML tags. An example with a JSP is as follows:
<html> <head> <meta name="_csrf" content="${_csrf.token}"/> <!-- default header name is X-CSRF-TOKEN --> <meta name="_csrf_header" content="${_csrf.headerName}"/> ... </head> …
Instead of manually creating the meta tags, you can use the simpler csrfMetaTags tag from the Spring Security JSP tag library.
Read now
Unlock full access