Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you protect against XSRF in Grails?

Tags:

grails

csrf

How does one protect against XSRF attacks in Grails. I see that forms support the notion of useToken which (I think should suffice). However, remoteForm or other AJAX related request don't support this feature.

Also, is there a way to invert the functionality of useToken so that it is always used rather than enabled on a case by case basis?

like image 719
Aaron Rustad Avatar asked Jan 18 '11 13:01

Aaron Rustad


1 Answers

You could try looking at the source code of the <g:form> tag. It uses a SynchronizerToken to create a token and store it in the session. Based on the resolution of this issue it should be possible to use the same token for all forms on the same page. I did not try this, but theoretically you would just need to manually create a hidden field on the form and generate the token in that field.

like image 127
Lauri Piispanen Avatar answered Oct 10 '22 05:10

Lauri Piispanen