Java webJava那些事

Java服务启用不安全的http方法解决方式

2020-04-02  本文已影响0人  Bruce基

说明

如果启用了不必要的HTTP方法可能会带来安全问题,如果启用了不必要的HTTP方法可能会带来安全问题。

image.png

解决方式是可以禁用掉不必要的方法。

解决

进入tomcat下修改conf目录的web.xml信息。

image.png

打开web.xml

vim web.xml

添加如下配置信息:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>fortune</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
        <http-method>HEAD</http-method>
        <http-method>OPTIONS</http-method>
        <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint></auth-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
</login-config>

配置如下:

image.png

重启

重启tomcat,检测。

说明

本文只做学习参考,如有任何不准确的地方欢迎指正。

我的邮箱:- lulongji2011@163.com

上一篇 下一篇

猜你喜欢

热点阅读