From e8e6af3a8f616d5d05e99281e8151af14bf3551d Mon Sep 17 00:00:00 2001
From: "Yangkai.Shen" <237497819@qq.com>
Date: Sat, 18 May 2019 19:26:35 +0800
Subject: [PATCH] =?UTF-8?q?:sparkles:=20spring-boot-demo-oauth=20=E5=BE=AE?=
=?UTF-8?q?=E4=BF=A1=20=E7=99=BB=E5=BD=95=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
spring-boot-demo-oauth/pom.xml | 2 +-
.../com/xkcoding/oauth/config/props/OAuthProperties.java | 1 +
.../com/xkcoding/oauth/controller/OauthController.java | 7 +++++++
spring-boot-demo-oauth/src/main/resources/application.yml | 6 +++++-
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/spring-boot-demo-oauth/pom.xml b/spring-boot-demo-oauth/pom.xml
index 1b4b2ac..8448b0b 100644
--- a/spring-boot-demo-oauth/pom.xml
+++ b/spring-boot-demo-oauth/pom.xml
@@ -49,7 +49,7 @@
me.zhyd.oauth
JustAuth
- 1.0.1
+ 1.2.0
diff --git a/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/config/props/OAuthProperties.java b/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/config/props/OAuthProperties.java
index bddaf6d..181cf21 100644
--- a/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/config/props/OAuthProperties.java
+++ b/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/config/props/OAuthProperties.java
@@ -26,4 +26,5 @@ public class OAuthProperties {
* github 配置
*/
private CommonProperties github;
+ private CommonProperties wechat;
}
diff --git a/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/controller/OauthController.java b/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/controller/OauthController.java
index 87a6d1c..cc1eb0f 100644
--- a/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/controller/OauthController.java
+++ b/spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/controller/OauthController.java
@@ -8,6 +8,7 @@ import me.zhyd.oauth.model.AuthResponse;
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;
@@ -66,6 +67,8 @@ public class OauthController {
switch (authSource) {
case GITHUB:
return getGithubAuthRequest();
+ case WECHAT:
+ return getWechatAuthRequest();
default:
throw new RuntimeException("暂不支持的第三方登录");
}
@@ -75,6 +78,10 @@ public class OauthController {
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())
diff --git a/spring-boot-demo-oauth/src/main/resources/application.yml b/spring-boot-demo-oauth/src/main/resources/application.yml
index d5b79ff..376262c 100644
--- a/spring-boot-demo-oauth/src/main/resources/application.yml
+++ b/spring-boot-demo-oauth/src/main/resources/application.yml
@@ -7,4 +7,8 @@ oauth:
github:
client-id: 2d25a70d12e3d5f01086
client-secret: 5a2919b5fe911567343aea2ccc7a5ad7871306d1
- redirect-uri: http://oauth.xkcoding.com/demo/oauth/github/callback
\ No newline at end of file
+ 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
\ No newline at end of file