Windows 服务器禁用Java update
1. 背景说明
Web安全测试中,会要求屏蔽非必要的不安全Http请求方法。一般要求保留get和post,其他的方法一般屏蔽,比如:OPTIONS,DELETE等。
本文主要收集业务系统中,不同时期,我们框架的各版本的处理方案,都基于tomcat+spring各版本体系。
2. 解决思路
使用tomcat自带的安全认证机制。配置对应的URL下的http方法访问都需要认证,但不配置认证方式,以实现对不安全的http方法的控制访问。主要应用的配置,原理上通过web.xml中的security-constraint节点进行定义。
具体相关参数的配置说明如下:
- web-resource-collection:此元素确定应该保护的资源。包含几个特定的子元素:
- url-pattern:表示受控的URL路径。
- http-method:表示受控的http请求方法。例如:OPTIONS
- http-method-omission:表示忽悠受控的http请求方法
- auth-constraint:指出哪些用户应该具有受保护资源的访问权,正常情况应该包含一个或多个标识具有访问权限的用户类别role-name元素。如果没有 <auth-constraint>这表明任何身份的用户都可以访问相应的资源,如果加入了 <auth-constraint> 子元素,但是其内容为空,这表示所有身份的用户都被禁止访问相应的资源。对应SecurityConstraint.setAuthConstraint(true);
- user-data-constraint:可选的元素指出在访问相关资源时使用任何传输层保护。它必须包含一个transport-guarantee子元素
- NONE:对所用的通讯协议不加限制
- CONFIDENTIAL:他们都只是简单地要求用SSL,一般是自动采用30x跳转。Api方式:SecurityConstraint.setUserConstraint("CONFIDENTIAL");
- INTEGRAL:类似CONFIDENTIAL
3. 解决方案
3.1 直接Tomcat部署
这种方式一般是在应用springboot前的模式,包括:spring2-spring4时代。采用直接修改工程的Web.xml来解决。
在你工程的web.xml中配置:
- 配置需要禁用的HTTP方法
- 配置允许访问的HTTP方法
以上两种方式,推荐使用:“配置允许访问的HTTP方法”
3.2 springboot1.x
使用springboot的autoconfig特性,为tomcat增加扩展的自动配置功能。
@Configuration @ConditionalOnWebApplication @ConditionalOnClass(Tomcat.class) public class TomcatAutoConfig { @Bean(name = "tomcatEmbeddedServletContainerFactory") public EmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() { TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() { @Override protected void postProcessContext(Context context) { SecurityConstraint securityConstraint = new SecurityConstraint(); securityConstraint.setAuthConstraint(true); SecurityCollection collection = new SecurityCollection(); collection.addPattern("/*"); collection.addOmittedMethod("GET"); collection.addOmittedMethod("get"); collection.addOmittedMethod("post"); collection.addOmittedMethod("POST"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint); } }; return tomcat; } }3.3 springboot2.x
原理同springboot1.x,只是在2.x版本后,可以直接采用TomcatServletWebServerFactory.addContextCustomizers发放增加ContextCustomizer扩展。
@Configuration @ConditionalOnWebApplication @ConditionalOnClass(Tomcat.class) public class TomcatAutoConfig { @Bean public WebServerFactoryCustomizer<TomcatServletWebServerFactory> acoolyWebServerFactoryCustomizer() { return factory -> { // 禁用内置Tomcat的不安全请求方法 factory.addContextCustomizers(context -> { SecurityConstraint securityConstraint = new SecurityConstraint(); // 开启认证 securityConstraint.setAuthConstraint(true); SecurityCollection collection = new SecurityCollection(); // 对所有资源生效 collection.addPattern("/*"); // 以下是排除认证的非安全http方法(安全的方法) collection.addOmittedMethod("GET"); collection.addOmittedMethod("get"); collection.addOmittedMethod("POS"); collection.addOmittedMethod("post"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint); }); }; } }Win10问题篇:彻底禁用 Windows 10 系统自动更新(使用Windows Update Blocker)如何彻底禁用win10自动更新
windows update国内服务器windows update服务器地址
部署Windows Server Update Services(WSUS)服务器Windows Server Update Services
Windows 10 1909 (Updated 2020-04-11)Windows 10, Version 1909 (Updated Jan 2020)
php生成pdf,php+tcpdf生成pdf, php pdf插件php pdf
如何彻底禁用Windows10自带的Windows Defender Firewall服务?windows defender firewall服务禁用
如何彻底禁用Windows10的Windows Defender Antivirus Servicewindows10网络禁用怎么启用
windows 10 & 禁用服务.batwindows10哪些服务可以禁用
windows服务器端禁止使用RC4加密算法 服务器禁止端口
Windows 8.1 & Windows 10 取消 Windows Update 自动更新硬件驱动Windows取消自动更新