av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

Springboot 使用內(nèi)置tomcat禁止不安全HTTP的方法

瀏覽:3日期:2023-02-26 18:25:28
Springboot 內(nèi)置tomcat禁止不安全HTTP方法1、在tomcat的web.xml中可以配置如下內(nèi)容

讓tomcat禁止不安全的HTTP方法

<security-constraint> <web-resource-collection><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>2、Spring boot使用內(nèi)置tomcat

沒有web.xml配置文件,可以通過以下配置進行,簡單來說就是要注入到Spring容器中

@Configurationpublic class TomcatConfig { @Bean public EmbeddedServletContainerFactory servletContainer() {TomcatEmbeddedServletContainerFactory tomcatServletContainerFactory = new TomcatEmbeddedServletContainerFactory();tomcatServletContainerFactory.addContextCustomizers(new TomcatContextCustomizer(){ @Override public void customize(Context context) { SecurityConstraint constraint = new SecurityConstraint(); SecurityCollection collection = new SecurityCollection(); //http方法 collection.addMethod('PUT'); collection.addMethod('DELETE'); collection.addMethod('HEAD'); collection.addMethod('OPTIONS'); collection.addMethod('TRACE'); //url匹配表達式 collection.addPattern('/*'); constraint.addCollection(collection); constraint.setAuthConstraint(true); context.addConstraint(constraint );//設(shè)置使用httpOnly context.setUseHttpOnly(true); }});return tomcatServletContainerFactory; } }啟用不安全的HTTP方法問題描述:

可能會在Web服務(wù)器上上載、修改或刪除Web頁面、腳本和文件。

’啟用了不安全的HTTP方法:OPTIONS /system HTTP/1.1Allow: HEAD, PUT, DELETE, TRACE, OPTIONS, PATCH

上述方法的用途:

Options、Head、Trace:主要由應(yīng)用程序來發(fā)現(xiàn)和跟蹤服務(wù)器支持和網(wǎng)絡(luò)行為; Get:檢索文檔; Put和Post:將文檔提交到服務(wù)器; Delete:銷毀資源或集合; Mkcol:創(chuàng)建集合 PropFind和PropPatch:針對資源和集合檢索和設(shè)置屬性; Copy和Move:管理命名空間上下文中的集合和資源; Lock和Unlock:改寫保護

很顯然上述操作明細可以對web服務(wù)器進行上傳、修改、刪除等操作,對服務(wù)造成威脅。雖然WebDAV有權(quán)限控制但是網(wǎng)上一搜還是一大堆的攻擊方法,所以如果不需要這些方法還是建議直接屏蔽就好了。

解決方案:

在web應(yīng)用中的web.xml加上如下內(nèi)容

<security-constraint><web-resource-collection> <web-resource-name>disp</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> <http-method>PATCH</http-method></web-resource-collection><auth-constraint></auth-constraint> </security-constraint>標簽介紹: <security-constraint>用于限制對資源的訪問; <auth-constraint>用于限制那些角色可以訪問資源,這里設(shè)置為空就是禁止所有角色用戶訪問; <url-pattern>指定需要驗證的資源 <http-method>指定那些方法需要驗證

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 中文字幕一区二区视频 | 先锋资源网站 | 欧美一级久久 | 91精品国产91综合久久蜜臀 | 福利视频一区二区 | 久久久做 | 日韩高清中文字幕 | 亚洲九色 | 欧美综合色| 欧美日韩视频在线第一区 | 人干人操| 欧美色综合一区二区三区 | 欧美九九 | 亚州中文| 久久国产婷婷国产香蕉 | 亚洲精品自在在线观看 | 黄页网址在线观看 | 国产a区| 97精品超碰一区二区三区 | 亚洲精品www久久久久久广东 | 日韩在线国产 | 天天干视频网 | 久久不射电影网 | 国产99久久精品一区二区永久免费 | 精品一二区 | 欧美a区 | 免费污视频 | 国产色播av在线 | 精品国产一区二区在线 | 天天操夜夜操 | 国产电影精品久久 | 欧美日在线 | 精久久久 | 龙珠z在线观看 | 成人中文字幕在线 | 日韩精品av| 真人毛片| 欧美性高潮 | 国产蜜臀 | 日韩亚洲一区二区 | 拍真实国产伦偷精品 |