|
@@ -1,7 +1,12 @@
|
|
|
package org.maxkey;
|
|
|
|
|
|
+import org.apache.catalina.Context;
|
|
|
+import org.apache.catalina.connector.Connector;
|
|
|
+import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
|
|
+import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
|
|
import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
|
|
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
|
|
|
import org.springframework.boot.web.server.ErrorPage;
|
|
|
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
|
@@ -56,4 +61,31 @@ public class MaxKeyConfig {
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Connector connector(){
|
|
|
+ Connector connector=new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
|
|
+ connector.setScheme("http");
|
|
|
+ connector.setPort(80);
|
|
|
+ connector.setSecure(false);
|
|
|
+ connector.setRedirectPort(443);
|
|
|
+ return connector;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public TomcatServletWebServerFactory tomcatServletWebServerFactory(Connector connector){
|
|
|
+ TomcatServletWebServerFactory tomcat=new TomcatServletWebServerFactory(){
|
|
|
+ @Override
|
|
|
+ protected void postProcessContext(Context context) {
|
|
|
+ SecurityConstraint securityConstraint=new SecurityConstraint();
|
|
|
+ securityConstraint.setUserConstraint("CONFIDENTIAL");
|
|
|
+ SecurityCollection collection=new SecurityCollection();
|
|
|
+ collection.addPattern("/*");
|
|
|
+ securityConstraint.addCollection(collection);
|
|
|
+ context.addConstraint(securityConstraint);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ tomcat.addAdditionalTomcatConnectors(connector);
|
|
|
+ return tomcat;
|
|
|
+ }
|
|
|
}
|