如何从Tomcat的Allow标头中删除PUT和DELETE方法

问题描述 投票:1回答:1

我们需要从现成的Tomcat 8.5中删除所谓的“不安全”方法。

当我们发出以下请求时:

OPTIONS * HTTP/1.1
Host: localhost:12080
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

我们收到此回复:

HTTP/1.1 200 
Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS
Content-Length: 0
Date: Mon, 18 May 2020 22:56:15 GMT

我们用<url-pattern>*</url-pattern>制作了一个WebFilter,它适用于OPTIONS / HTTP/1.1OPTIONS * HTTP/1.1以外的其他任何选项。

¿我们如何过滤(或屏蔽)OPTIONS * HTTP/1.1

security tomcat filter
1个回答
0
投票

您可以使用安全性约束在应用程序web.xml文件中禁用OPTIONS方法。

<security-constraint>
<web-resource-collection>
<web-resource-name>restricted methods</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>OPTIONS</http-method>
</web-resource-collection>
<auth-constraint />
</security-constraint>
© www.soinside.com 2019 - 2024. All rights reserved.