我将 Apache Jackrabbit 2.6.3 配置为以匿名模式使用 WebDAV(空凭据映射到 anonymous:anonymous
)。
如果我单击某个文件(例如 JPG 或 DOC)的直接链接,GlassFish 服务器会抛出 HTTP 403 错误。如果我按 F5,403 仍然存在。
但是,如果我只需在浏览器的地址栏中按相同 URL 的 Enter,一切都会正常,并且可以访问资源。
我认为唯一的区别是 HTTP header 中的引用者。
我搜索了有关类似问题的任何信息,但找不到任何内容。
是否有人知道如何强制 WebDAV(或 Jackrabbit)以匿名模式提供文件,尽管存在引荐来源网址或任何其他原因?
最佳答案
我找到了解决方案。
在 web.xml
文件的 WebDAV
部分中,必须取消注释以下部分:
<init-param>
<param-name>csrf-protection</param-name>
<param-value>disabled</param-value>
</init-param>
将disabled
作为param-value
。
正如描述所说:
Defines the behaviour of the referrer based CSRF protection
1) If omitted or left empty the (default) behaviour is to allow only requests with
an empty referrer header or a referrer host equal to the server host
2) May also contain a comma separated list of additional allowed referrer hosts
3) If set to 'disabled' no referrer checking will be performed at all
关于Apache Jackrabbit 在 WebDAV 匿名访问中抛出 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18331871/