Rav*_*ara 1 java rest tomcat servlets security-constraint
我有一个用 Restful webservice 和 java 开发的 web 应用程序。我正在使用泽西图书馆。我的团队在应用程序上运行了 Appscan 工具。该工具显示在 https:///AppName/ 上启用了不安全的 HTTP 方法。
编辑: 1.我想知道如何在此处禁用 DELETE 方法。2.当我向服务器发出选项请求时,它不应该在标题中的允许方法中列出删除方法。提前致谢。
在web.xml安全约束中定义所需 URL 模式和给定 HTTP 方法的空身份验证约束。
下面的示例限制 ALLDELETE和TRACE请求,而不管 URL 和用户。
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted HTTP methods.</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>TRACE</http-method>
<!-- You can specify multiple HTTP methods here. -->
</web-resource-collection>
<auth-constraint />
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
效果是HTTP 403 Forbidden响应。