Skip to content

Commit

Permalink
✨ spring-boot-demo-oauth 微信 登录完成
Browse files Browse the repository at this point in the history
  • Loading branch information
xkcoding committed May 20, 2019
1 parent ad8d343 commit e8e6af3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spring-boot-demo-oauth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.0.1</version>
<version>1.2.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public class OAuthProperties {
* github 配置
*/
private CommonProperties github;
private CommonProperties wechat;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.request.AuthGithubRequest;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.request.AuthWeChatRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -66,6 +67,8 @@ private AuthRequest getAuthRequest(String oauthType) {
switch (authSource) {
case GITHUB:
return getGithubAuthRequest();
case WECHAT:
return getWechatAuthRequest();
default:
throw new RuntimeException("暂不支持的第三方登录");
}
Expand All @@ -75,6 +78,10 @@ private AuthRequest getGithubAuthRequest() {
return new AuthGithubRequest(buildAuthConfig(properties.getGithub()));
}

private AuthRequest getWechatAuthRequest() {
return new AuthWeChatRequest(buildAuthConfig(properties.getWechat()));
}

private AuthConfig buildAuthConfig(CommonProperties properties) {
return AuthConfig.builder()
.clientId(properties.getClientId())
Expand Down
6 changes: 5 additions & 1 deletion spring-boot-demo-oauth/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ oauth:
github:
client-id: 2d25a70d12e3d5f01086
client-secret: 5a2919b5fe911567343aea2ccc7a5ad7871306d1
redirect-uri: http://oauth.xkcoding.com/demo/oauth/github/callback
redirect-uri: http://oauth.xkcoding.com/demo/oauth/github/callback
wechat:
client-id:
client-secret:
redirect-uri: http://oauth.xkcoding.com/demo/oauth/wechat/callback

0 comments on commit e8e6af3

Please sign in to comment.