如何在java中的应用程序中禁用不安全的HTTP方法

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

我有一个在Restful webservice和java中开发的Web应用程序。我使用泽西岛图书馆。我的团队在应用程序上运行了Appscan工具。该工具在https:/// AppName /上启用了不安全的HTTP方法。

编辑:1。我想知道如何在这里禁用DELETE方法。 2.当我向服务器发出选项请求时,它不应该在标头中的允许方法中列出删除方法。提前致谢。

java rest tomcat servlets security-constraint
1个回答
4
投票

web.xml中定义一个安全约束,在所需的URL模式和给定的HTTP方法上使用空的auth约束。

以下示例限制所有DELETETRACE请求,无论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>

效果是HTTP 403 Forbidden反应。

© www.soinside.com 2019 - 2024. All rights reserved.