Search code examples
spring-securityprimefacescsrf

Make Primefaces file upload button to work, in a primefaces + spring website when CSRF protection is enabled without avoiding the protection


I have a demo application consisting of one form (dashboard.xhtml) which allows user to select a file and then add a row to a table. To do this, it has two Primefaces File upload buttons, the first uses simple mode to load files, the second uses advanced mode.

enter image description here

When CSRF (Cross-site request forgery) protection (http.csrf().disable(); in WebSecurityConfigurer) is disabled, both buttons work fine, but as soon as I Enable CSRF protection (by commenting out the line http.csrf().disable(); ) the simple mode button stops working. Application is built with Maven and JSF 2.3.14, Spring 5.3.27 and Primefaces 12.0.0 frameworks.

screenshot. enter image description here enter image description here enter image description here

I tried to use JSF upload button, it is working fine but the designed is not aligned with Primefaces simple mode button and I'm not able to modify it.


Solution

  • This has been fixed for PrimeFaces 13.0.6: https://github.com/primefaces/primefaces/pull/11427