ssl support

ssl support
This commit is contained in:
shimingxy
2020-02-06 14:03:35 +08:00
parent d294444352
commit 9bac9464a1
6 changed files with 60 additions and 20 deletions

View File

@@ -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;
}
}

View File

@@ -1,7 +1,15 @@
#server config
#spring.profiles.active=dev
#server port
server.port=80
#server.port=80
server.port=443
#ssl
server.ssl.key-store=maxkeyserver.keystore
server.ssl.key-alias=maxkey
server.ssl.enabled=true
server.ssl.key-store-password=maxkey
server.ssl.key-store-type=JKS
#web app context path
server.servlet.context-path=/maxkey
@@ -22,4 +30,4 @@ spring.freemarker.suffix=.ftl
#static resources
spring.mvc.static-path-pattern=/static/**
spring.main.allow-bean-definition-overriding=true
spring.main.allow-bean-definition-overriding=true

View File

@@ -120,14 +120,14 @@ config.socialsignon.dingtalk.client.secret=Crm7YJbMKfRlvG2i1SHpg4GHVpqF_oXiEjhmR
config.socialsignon.dingtalk.account.id=openid
config.socialsignon.dingtalk.sortorder=4
#Windows Live
config.socialsignon.live.provider=Windows
config.socialsignon.live.provider.name=Windows Live
config.socialsignon.live.icon=images/social/live.png
config.socialsignon.live.client.id=00000000401129A4
config.socialsignon.live.client.secret=Kx-OAmHaoqG5vcitm3-TASOSZD1ebu64
config.socialsignon.live.account.id=id
config.socialsignon.live.sortorder=5
#Microsoft
config.socialsignon.microsoft.provider=microsoft
config.socialsignon.microsoft.provider.name=Microsoft
config.socialsignon.microsoft.icon=images/social/live.png
config.socialsignon.microsoft.client.id=24aa73b6-7928-4e64-bd64-d8682e650f95
config.socialsignon.microsoft.client.secret=PF[_AthtjVrtWVO2mNy@CJxY1@Z8FNf5
config.socialsignon.microsoft.account.id=id
config.socialsignon.microsoft.sortorder=5
#facebook
config.socialsignon.facebook.provider=facebook

View File

@@ -49,13 +49,13 @@
<property name="sortOrder" value="${config.socialsignon.qq.sortorder}"/>
</bean>
<bean id="socialSignOnLive" class="org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider">
<property name="provider" value="${config.socialsignon.live.provider}"/>
<property name="providerName" value="${config.socialsignon.live.provider.name}"/>
<property name="icon" value="${config.socialsignon.live.icon}"/>
<property name="clientId" value="${config.socialsignon.live.client.id}"/>
<property name="clientSecret" value="${config.socialsignon.live.client.secret}"/>
<property name="sortOrder" value="${config.socialsignon.live.sortorder}"/>
<bean id="socialSignOnMicrosoft" class="org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider">
<property name="provider" value="${config.socialsignon.microsoft.provider}"/>
<property name="providerName" value="${config.socialsignon.microsoft.provider.name}"/>
<property name="icon" value="${config.socialsignon.microsoft.icon}"/>
<property name="clientId" value="${config.socialsignon.microsoft.client.id}"/>
<property name="clientSecret" value="${config.socialsignon.microsoft.client.secret}"/>
<property name="sortOrder" value="${config.socialsignon.microsoft.sortorder}"/>
</bean>
<bean id="socialSignOnFacebook" class="org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider">
@@ -81,7 +81,7 @@
<ref bean="socialSignOnWeibo" />
<ref bean="socialSignOnQQ"/>
<ref bean="socialSignOnGoogle"/>
<ref bean="socialSignOnLive"/>
<ref bean="socialSignOnMicrosoft"/>
<ref bean="socialSignOnFacebook"/>
<ref bean="socialSignOndingtalk"/>