mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-18 22:38:09 +08:00
社交账号关联调整及优化
社交账号关联调整及优化
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package org.maxkey;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
||||
@@ -17,9 +14,6 @@ import org.maxkey.authn.realm.activedirectory.ActiveDirectoryAuthenticationRealm
|
||||
import org.maxkey.authn.realm.activedirectory.ActiveDirectoryServer;
|
||||
import org.maxkey.authn.support.kerberos.KerberosProxy;
|
||||
import org.maxkey.authn.support.kerberos.RemoteKerberosService;
|
||||
import org.maxkey.authn.support.socialsignon.service.JdbcSocialsAssociateService;
|
||||
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider;
|
||||
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
|
||||
import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
|
||||
@@ -34,16 +28,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
|
||||
@@ -69,8 +59,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
"org.maxkey.authz.exapi.endpoint",
|
||||
"org.maxkey.authz.formbased.endpoint",
|
||||
"org.maxkey.authz.ltpa.endpoint",
|
||||
"org.maxkey.authz.token.endpoint",
|
||||
"org.maxkey.web.authentication.support.socialsignon"
|
||||
"org.maxkey.authz.token.endpoint"
|
||||
})
|
||||
public class MaxKeyConfig implements InitializingBean {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyConfig.class);
|
||||
@@ -239,45 +228,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
return kerberosService;
|
||||
}
|
||||
|
||||
@Bean(name = "socialSignOnProviderService")
|
||||
@ConditionalOnClass(SocialSignOnProvider.class)
|
||||
public SocialSignOnProviderService socialSignOnProviderService() throws IOException {
|
||||
SocialSignOnProviderService socialSignOnProviderService = new SocialSignOnProviderService();
|
||||
|
||||
Resource resource = new ClassPathResource(
|
||||
ConstantsProperties.classPathResource(ConstantsProperties.classPathResource(ConstantsProperties.maxKeyPropertySource)));
|
||||
Properties properties = new Properties();
|
||||
properties.load(resource.getInputStream());
|
||||
String [] providerList =properties.get("config.login.socialsignon.providers").toString().split(",");
|
||||
List<SocialSignOnProvider> socialSignOnProviderList = new ArrayList<SocialSignOnProvider>();
|
||||
for(String provider : providerList) {
|
||||
String providerName = properties.getProperty("config.socialsignon."+provider+".provider.name");
|
||||
String icon=properties.getProperty("config.socialsignon."+provider+".icon");
|
||||
String clientId=properties.getProperty("config.socialsignon."+provider+".client.id");
|
||||
String clientSecret=properties.getProperty("config.socialsignon."+provider+".client.secret");
|
||||
String sortOrder = properties.getProperty("config.socialsignon."+provider+".sortorder");
|
||||
SocialSignOnProvider socialSignOnProvider = new SocialSignOnProvider();
|
||||
socialSignOnProvider.setProvider(provider);
|
||||
socialSignOnProvider.setProviderName(providerName);
|
||||
socialSignOnProvider.setIcon(icon);
|
||||
socialSignOnProvider.setClientId(clientId);
|
||||
socialSignOnProvider.setClientSecret(clientSecret);
|
||||
socialSignOnProvider.setSortOrder(Integer.valueOf(sortOrder));
|
||||
_logger.debug("socialSignOnProvider " + socialSignOnProvider);
|
||||
socialSignOnProviderList.add(socialSignOnProvider);
|
||||
}
|
||||
socialSignOnProviderService.setSocialSignOnProviders(socialSignOnProviderList);
|
||||
_logger.debug("SocialSignOnProviderService inited.");
|
||||
return socialSignOnProviderService;
|
||||
}
|
||||
|
||||
@Bean(name = "socialsAssociateService")
|
||||
public JdbcSocialsAssociateService socialsAssociateService(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcSocialsAssociateService socialsAssociateService = new JdbcSocialsAssociateService(jdbcTemplate);
|
||||
_logger.debug("JdbcSocialsAssociateService inited.");
|
||||
return socialsAssociateService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package org.maxkey.autoconfigure;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.maxkey.authn.support.socialsignon.service.JdbcSocialsAssociateService;
|
||||
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider;
|
||||
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {
|
||||
"org.maxkey.authn.support.socialsignon"
|
||||
})
|
||||
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||
public class SocialSignOnAutoConfiguration implements InitializingBean {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(SocialSignOnAutoConfiguration.class);
|
||||
|
||||
@Bean(name = "socialSignOnProviderService")
|
||||
@ConditionalOnClass(SocialSignOnProvider.class)
|
||||
public SocialSignOnProviderService socialSignOnProviderService() throws IOException {
|
||||
SocialSignOnProviderService socialSignOnProviderService = new SocialSignOnProviderService();
|
||||
|
||||
Resource resource = new ClassPathResource(
|
||||
ConstantsProperties.classPathResource(ConstantsProperties.classPathResource(ConstantsProperties.maxKeyPropertySource)));
|
||||
Properties properties = new Properties();
|
||||
properties.load(resource.getInputStream());
|
||||
String [] providerList =properties.get("config.login.socialsignon.providers").toString().split(",");
|
||||
List<SocialSignOnProvider> socialSignOnProviderList = new ArrayList<SocialSignOnProvider>();
|
||||
for(String provider : providerList) {
|
||||
String providerName = properties.getProperty("config.socialsignon."+provider+".provider.name");
|
||||
String icon=properties.getProperty("config.socialsignon."+provider+".icon");
|
||||
String clientId=properties.getProperty("config.socialsignon."+provider+".client.id");
|
||||
String clientSecret=properties.getProperty("config.socialsignon."+provider+".client.secret");
|
||||
String sortOrder = properties.getProperty("config.socialsignon."+provider+".sortorder");
|
||||
SocialSignOnProvider socialSignOnProvider = new SocialSignOnProvider();
|
||||
socialSignOnProvider.setProvider(provider);
|
||||
socialSignOnProvider.setProviderName(providerName);
|
||||
socialSignOnProvider.setIcon(icon);
|
||||
socialSignOnProvider.setClientId(clientId);
|
||||
socialSignOnProvider.setClientSecret(clientSecret);
|
||||
socialSignOnProvider.setSortOrder(Integer.valueOf(sortOrder));
|
||||
_logger.debug("socialSignOnProvider " + socialSignOnProvider);
|
||||
socialSignOnProviderList.add(socialSignOnProvider);
|
||||
}
|
||||
socialSignOnProviderService.setSocialSignOnProviders(socialSignOnProviderList);
|
||||
_logger.debug("SocialSignOnProviderService inited.");
|
||||
return socialSignOnProviderService;
|
||||
}
|
||||
|
||||
@Bean(name = "socialsAssociateService")
|
||||
public JdbcSocialsAssociateService socialsAssociateService(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcSocialsAssociateService socialsAssociateService = new JdbcSocialsAssociateService(jdbcTemplate);
|
||||
_logger.debug("JdbcSocialsAssociateService inited.");
|
||||
return socialsAssociateService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user