|
@@ -0,0 +1,39 @@
|
|
|
+package com.jiayue.ssi.config;
|
|
|
+
|
|
|
+import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
|
|
+import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
|
|
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
|
|
+import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+
|
|
|
+/**
|
|
|
+*
|
|
|
+*
|
|
|
+* @author xsl
|
|
|
+* @since 2023/07/11
|
|
|
+*/
|
|
|
+@Configuration
|
|
|
+public class TomcatCustomizer{
|
|
|
+ @Bean
|
|
|
+ public ConfigurableServletWebServerFactory configurableServletWebServerFactory() {
|
|
|
+ TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
|
|
+ factory.addContextCustomizers(context -> {
|
|
|
+ SecurityConstraint securityConstraint = new SecurityConstraint();
|
|
|
+ securityConstraint.setUserConstraint("CONFIDENTIAL");
|
|
|
+ SecurityCollection collection = new SecurityCollection();
|
|
|
+ collection.addPattern("/*");
|
|
|
+ collection.addMethod("HEAD");
|
|
|
+ collection.addMethod("PUT");
|
|
|
+ collection.addMethod("DELETE");
|
|
|
+ collection.addMethod("OPTIONS");
|
|
|
+ collection.addMethod("TRACE");
|
|
|
+ collection.addMethod("COPY");
|
|
|
+ collection.addMethod("SEARCH");
|
|
|
+ collection.addMethod("PROPFIND");
|
|
|
+ securityConstraint.addCollection(collection);
|
|
|
+ context.addConstraint(securityConstraint);
|
|
|
+ });
|
|
|
+ return factory;
|
|
|
+ }
|
|
|
+}
|