forked from longfeizheng/logback
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加微博社交登录(参考连接:https://github.com/vergnes/spring-social-weibo)
- Loading branch information
1 parent
e07a808
commit edf359a
Showing
5 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/cn/merryyou/logback/social/weibo/config/WeiboAuthConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cn.merryyou.logback.social.weibo.config; | ||
|
||
import cn.merryyou.logback.properties.SecurityConstants; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.crypto.encrypt.Encryptors; | ||
import org.springframework.social.connect.ConnectionFactory; | ||
import org.springframework.social.connect.ConnectionFactoryLocator; | ||
import org.springframework.social.connect.ConnectionSignUp; | ||
import org.springframework.social.connect.UsersConnectionRepository; | ||
import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository; | ||
import org.springframework.social.weibo.connect.WeiboConnectionFactory; | ||
|
||
import javax.sql.DataSource; | ||
|
||
|
||
/** | ||
* Created on 2018/1/12. | ||
* | ||
* @author zlf | ||
* @since 1.0 | ||
*/ | ||
@Configuration | ||
public class WeiboAuthConfig extends SocialAutoConfigurerAdapter { | ||
@Autowired | ||
private DataSource dataSource; | ||
|
||
@Autowired | ||
private ConnectionSignUp myConnectionSignUp; | ||
|
||
@Override | ||
protected ConnectionFactory<?> createConnectionFactory() { | ||
return new WeiboConnectionFactory(SecurityConstants.DEFAULT_SOCIAL_WEIBO_APP_ID, SecurityConstants.DEFAULT_SOCIAL_WEIBO_APP_SECRET); | ||
} | ||
|
||
@Override | ||
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) { | ||
JdbcUsersConnectionRepository repository = new JdbcUsersConnectionRepository(dataSource, | ||
connectionFactoryLocator, Encryptors.noOpText()); | ||
if (myConnectionSignUp != null) { | ||
repository.setConnectionSignUp(myConnectionSignUp); | ||
} | ||
return repository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters