【发布时间】:2014-06-10 23:20:52
【问题描述】:
我的应用程序具有 apache 模块提供的 CSRF 保护。我的应用程序包含一些允许上传文件的页面,如下所示:
<form:form method="post" action="my.controller" enctype="multipart/form-data" id="form">
当我们将 apache 版本从 httpd-2.2.3 更新为 httpd-2.2.15 时,所有东西都运行良好。
我搜索了一段时间,发现问题可能与我的表单中的 multipart/form-data 参数有关。在这种情况下,表单发送为不安全。我还发现 spring 可以通过 spring doc http://docs.spring.io/spring-security/site/docs/3.2.0.CI-SNAPSHOT/reference/html/csrf.html#csrf-multipartfilter
中的MultipartFilter 处理上述内容
我是 CSRF 方面的新手。很高兴知道是否可以将 spring CSRF protection 与 apache 配置一起使用来处理此类情况。
我还找到了解决方法,可以为所需的 URL 禁用 CSRF,例如
RewriteRule /url/mycontroller.controller - [E=CSRF_IGNORE:yes]
但我不确定它在哪里是正确的。
【问题讨论】: