social 代码整理

私服配置
This commit is contained in:
wangiegie@gmail.com 2018-01-19 16:17:44 +08:00
parent 3cd7841eb7
commit d34f4c0539
9 changed files with 87 additions and 24 deletions

View File

@ -2,12 +2,10 @@ package com.github.pig.auth.component.social.qq.config;
import com.github.pig.auth.component.social.qq.connect.QQConnectionFactory;
import com.github.pig.auth.component.social.repository.PigUsersConnectionRepository;
import com.github.pig.common.constant.SecurityConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.social.connect.ConnectionFactory;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionSignUp;
@ -23,24 +21,27 @@ import org.springframework.social.connect.UsersConnectionRepository;
@Configuration
public class QQAuthConfig extends SocialAutoConfigurerAdapter {
@Autowired
private ConnectionSignUp myConnectionSignUp;
private SocialQQPropertiesConfig socialQQPropertiesConfig;
@Autowired
private ConnectionSignUp pigConnectionSignUp;
@Override
protected ConnectionFactory<?> createConnectionFactory() {
return new QQConnectionFactory(SecurityConstants.DEFAULT_SOCIAL_QQ_PROVIDER_ID, SecurityConstants.DEFAULT_SOCIAL_QQ_APP_ID, SecurityConstants.DEFAULT_SOCIAL_QQ_APP_SECRET);
return new QQConnectionFactory(socialQQPropertiesConfig.getProviderId(),
socialQQPropertiesConfig.getClientId(), socialQQPropertiesConfig.getClientSecret());
}
@Override
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
PigUsersConnectionRepository repository = new PigUsersConnectionRepository();
repository.setConnectionSignUp(myConnectionSignUp);
repository.setConnectionSignUp(pigConnectionSignUp);
return repository;
}
@Bean
public UsersConnectionRepository usersConnectionRepository(){
PigUsersConnectionRepository repository = new PigUsersConnectionRepository();
repository.setConnectionSignUp(myConnectionSignUp);
repository.setConnectionSignUp(pigConnectionSignUp);
return repository;
}
}

View File

@ -0,0 +1,15 @@
package com.github.pig.auth.component.social.qq.config;
import com.github.pig.auth.config.SocialPropertiesConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author lengleng
* @date 2018/1/19
* QQ登录参数配置
*/
@Configuration
@ConfigurationProperties(prefix = "pig.social.qq")
public class SocialQQPropertiesConfig extends SocialPropertiesConfig {
}

View File

@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
* @since 1.0
*/
@Component
public class MyConnectionSignUp implements ConnectionSignUp {
public class PigConnectionSignUp implements ConnectionSignUp {
@Override
public String execute(Connection<?> connection) {
//根据社交用户信息默认创建用户并返回用户唯一标识

View File

@ -0,0 +1,25 @@
package com.github.pig.auth.config;
import lombok.Data;
/**
* @author lengleng
* @date 2017/10/28
* social 登录基础配置
*/
@Data
public class SocialPropertiesConfig {
/**
* 提供商
*/
private String providerId;
/**
* 应用ID
*/
private String clientId;
/**
* 应用密钥
*/
private String clientSecret;
}

View File

@ -0,0 +1,35 @@
package com.github.pig.common.bean.interceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.*;
import java.sql.Connection;
import java.util.Properties;
/**
* @author lengleng
* @date 2018/1/19
* 数据权限插件参考PaginationInterceptor
*/
@Slf4j
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
public class DataScopeInterceptor implements Interceptor{
@Override
public Object intercept(Invocation invocation) throws Throwable {
return invocation.proceed();
}
@Override
public Object plugin(Object target) {
if (target instanceof StatementHandler) {
return Plugin.wrap(target, this);
}
return target;
}
@Override
public void setProperties(Properties properties) {
}
}

View File

@ -86,20 +86,6 @@ public interface SecurityConstants {
*/
String AUTH_SERVICE_ID = "auth-service";
/**
* qq appID
*/
String DEFAULT_SOCIAL_QQ_APP_ID = "101322838";
/**
* qq appsECRET
*/
String DEFAULT_SOCIAL_QQ_APP_SECRET = "fe6ec1ed3fc45e664ce8ddbf78376ab7";
/**
* 提供商的ID
*/
String DEFAULT_SOCIAL_QQ_PROVIDER_ID = "qq";
/**
* 默认的social的登录地址
*/

View File

@ -33,8 +33,8 @@
<groupId>com.aliyun.taobao</groupId>
<artifactId>alidayu-sms</artifactId>
<version>1.0</version>
<!--<scope>system</scope>-->
<!--<systemPath>${basedir}/src/main/resources/lib/alidayu-sms-1.0.jar</systemPath>-->
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/lib/alidayu-sms-1.0.jar</systemPath>
</dependency>
</dependencies>

View File

@ -21,6 +21,8 @@ public class PigAdminApplicationTest {
System.out.println(stringEncryptor.encrypt("g0HJr2Ltrs0k6tJDY6pDI2aVMUCPSWZDTROLcFMs"));
System.out.println(stringEncryptor.encrypt("24760324"));
System.out.println(stringEncryptor.encrypt("175d516debb916d3842d981dd3b76061"));
System.out.println(stringEncryptor.encrypt("101322838"));
System.out.println(stringEncryptor.encrypt("fe6ec1ed3fc45e664ce8ddbf78376ab7"));
}
}

View File

@ -140,5 +140,4 @@
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>