创建第三方授权数据表
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- This SQL contains a "create table" that can be used to create a table that JdbcUsersConnectionRepository can persist
|
||||
-- connection in. It is, however, not to be assumed to be production-ready, all-purpose SQL. It is merely representative
|
||||
-- of the kind of table that JdbcUsersConnectionRepository works with. The table and column names, as well as the general
|
||||
-- column types, are what is important. Specific column types and sizes that work may vary across database vendors and
|
||||
-- the required sizes may vary across API providers.
|
||||
USE micro;
|
||||
create table upms_UserConnection (userId varchar(255) not null,
|
||||
providerId varchar(255) not null,
|
||||
providerUserId varchar(255),
|
||||
rank int not null,
|
||||
displayName varchar(255),
|
||||
profileUrl varchar(512),
|
||||
imageUrl varchar(512),
|
||||
accessToken varchar(512) not null,
|
||||
secret varchar(512),
|
||||
refreshToken varchar(512),
|
||||
expireTime bigint,
|
||||
primary key (userId, providerId, providerUserId));
|
||||
create unique index UserConnectionRank on upms_UserConnection(userId, providerId, rank);
|
||||
+8
-2
@@ -19,6 +19,9 @@ import javax.sql.DataSource;
|
||||
@EnableSocial
|
||||
public class SocialConfig extends SocialConfigurerAdapter{
|
||||
|
||||
/**
|
||||
* 使用的数据源
|
||||
*/
|
||||
@Autowired
|
||||
@Qualifier("dynamicDataSource")
|
||||
private DataSource dataSource;
|
||||
@@ -30,7 +33,10 @@ public class SocialConfig extends SocialConfigurerAdapter{
|
||||
*/
|
||||
@Override
|
||||
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
|
||||
//第三参数是加解密的策略,这里指定是不做加解密操作
|
||||
return new JdbcUsersConnectionRepository(dataSource,connectionFactoryLocator, Encryptors.noOpText());
|
||||
//第三参数是加解密的策略,这里指定是不做加解密操作。对插入到数据库中的信息进行加解密
|
||||
JdbcUsersConnectionRepository jdbcUsersConnectionRepository = new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator, Encryptors.noOpText());
|
||||
//使用OAuth2.sql创建如果数据表自定义前缀的话在这里声明
|
||||
jdbcUsersConnectionRepository.setTablePrefix("upms_");
|
||||
return jdbcUsersConnectionRepository;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -10,9 +10,9 @@ import org.springframework.social.connect.support.OAuth2ConnectionFactory;
|
||||
public class QQConnectionFactory extends OAuth2ConnectionFactory<QQ> {
|
||||
/**
|
||||
* 使用连接工厂创建连接
|
||||
* @param providerId
|
||||
* @param appId
|
||||
* @param appSecret
|
||||
* @param providerId 服务提供商的唯一标识
|
||||
* @param appId 应用系统登录第三方授权的用户名
|
||||
* @param appSecret 应用系统登录第三方授权的密码
|
||||
*/
|
||||
public QQConnectionFactory(String providerId
|
||||
,String appId,String appSecret) {
|
||||
|
||||
Reference in New Issue
Block a user