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 :
Then register it to override the FormRenderer by setting it in
faces-config.xml
:I've tried to create a Component then add it as children but it wouldn't let me set the name of the input correctly so I directly write it.