diff --git a/README.en-US.md b/README.en-US.md
index d4c51dce76f3015adde8e6ee8f04b95fa13a37ce..00c363018eb34dae8b68096e507a35e8871f3248 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -44,7 +44,7 @@
|
|
|
- |
+ |
|
|
|
@@ -62,6 +62,7 @@
|
|
|
+ |
|
|
|
@@ -96,7 +97,7 @@ These artifacts are available from Maven Central:
me.zhyd.oauth
JustAuth
- 1.13.2
+ 1.14.0
```
- Using JustAuth
diff --git a/README.md b/README.md
index 0f95a01ade7b1a6df7de38abfa386a0e96c21ed5..39c1bb3861aa19fa3d3ac6d5d7a1569ed97eaa8d 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -44,7 +44,7 @@
|
|
|
- |
+ |
|
|
|
@@ -97,7 +97,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
me.zhyd.oauth
JustAuth
- 1.13.2
+ 1.14.0
```
- 调用api
diff --git a/bin/version.txt b/bin/version.txt
index 61ce01b30118c7209a61d0a8129b390f02e2e01d..850e742404bba0ccc0dde11877e9737d6fe8f479 100644
--- a/bin/version.txt
+++ b/bin/version.txt
@@ -1 +1 @@
-1.13.2
+1.14.0
diff --git a/docs/README.md b/docs/README.md
index 1ce1f84ace649f1abf2e1694fa087a559201c436..9cf6c9851db26cf4dacd1308a17f556341e8ee5e 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -9,7 +9,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
diff --git a/docs/_coverpage.md b/docs/_coverpage.md
index 582d69af73d8784823b243cc3e62ac996fcdbe5c..3c880a258917d5aa902f954a8087352e12c8b2e5 100644
--- a/docs/_coverpage.md
+++ b/docs/_coverpage.md
@@ -1,6 +1,6 @@
![](_media/logo.png)
-# JustAuth 1.13.2
+# JustAuth 1.14.0
史上最全的整合第三方登录的开源库
diff --git a/docs/_sidebar.md b/docs/_sidebar.md
index 62f9f210be8a0bedba797c03add18bd8a2802669..b91467d6d3760b9975ad04ee0da8979e596985f7 100644
--- a/docs/_sidebar.md
+++ b/docs/_sidebar.md
@@ -10,6 +10,8 @@
- [√ Github登录](oauth/github.md)
- [√ qq登录](oauth/qq.md)
- [√ 微信开放平台登录](oauth/wechat_open.md)
+ - [微信企业版登录](oauth/wechatEnterprise.md)
+ - [微信公众平台登录](oauth/wechat_mp.md)
- [√ 微博登录](oauth/weibo.md)
- [√ 支付宝登录](oauth/alipay.md)
- [百度登录](oauth/baidu.md)
@@ -30,12 +32,12 @@
- [Pinterest登录](oauth/pinterest.md)
- [Stackoverflow登录](oauth/stackoverflow.md)
- [华为登录](oauth/huawei.md)
- - [微信企业版登录](oauth/wechatEnterprise.md)
- [√ 酷家乐登录](oauth/kujiale.md)
- [Gitlab登录](oauth/gitlab.md)
- [美团登录](oauth/meituan.md)
- [饿了么登录](oauth/eleme.md)
- [CSDN登录](oauth/csdn.md)
+ - [飞书登录](oauth/feishu.md)
- 高级特性
- [使用State](using-state.md)
- [自定义state缓存](customize-the-state-cache.md)
diff --git a/docs/contributors.md b/docs/contributors.md
index ad11a9e87e9b8bfe35de90e82d8539738c4ce960..41d7022612f75cedbfe94359f6aa11730661f11d 100644
--- a/docs/contributors.md
+++ b/docs/contributors.md
@@ -26,6 +26,10 @@
- 添加测试用例:UrlBuilder 、GlobalAuthUtil
- · Chris Smowton : [Github]
- 添加测试用例:StringUtils
+- · githubeacon : [Github]
+ - 增加飞书授权登录
+- · runningzyp : [Github]
+ - 修改文案错误
- 千年等一回,我只为等你...
ps: 如有遗漏,请告知
diff --git a/docs/oauth/wechat_mp.md b/docs/oauth/wechat_mp.md
new file mode 100644
index 0000000000000000000000000000000000000000..ff4be0a26eca5abbe877d4899fb9c919d230fccc
--- /dev/null
+++ b/docs/oauth/wechat_mp.md
@@ -0,0 +1,10 @@
+(敬请期待...)
+
+### 声明:
+此文档适用于**微信公众平台**!
+
+## 1. 申请应用
+
+## 2. 集成JustAuth
+
+## 3. 授权结果
\ No newline at end of file
diff --git a/docs/oauth/wechat_open.md b/docs/oauth/wechat_open.md
index 9dd2bd16016d1d161e1e48a80c25b2b17f7c191a..18283b1fe042ee004b64e2a048b99033a878ffcc 100644
--- a/docs/oauth/wechat_open.md
+++ b/docs/oauth/wechat_open.md
@@ -1,5 +1,5 @@
### 声明:
-此文档适用于**微信开放平台**、**微信开放平台**、**微信开放平台**,不是**微信公众平台**!
+此文档适用于**微信开放平台**!
## 1. 申请应用
diff --git a/docs/update.md b/docs/update.md
index dae31bda6fbf6809bde89a291c407a1303a319b5..8512a4c49fa7038d420780b169779804ee0fa5ab 100644
--- a/docs/update.md
+++ b/docs/update.md
@@ -1,3 +1,10 @@
+## v1.14.0
+### 2020/03/17
+- 修改
+ - 合并[PR-59](https://github.com/justauth/JustAuth/pull/59),抽取HTTP,具体实现交给开发者,解耦 hutool-http,开发者可以视自己项目的依赖决定使用何种HTTP方式。详情请参考:https://github.com/xkcoding/simple-http
+ - 合并[PR-65](https://github.com/justauth/JustAuth/pull/65),修改错误文案
+ - 修复其他一些问题
+
## v1.13.2
### 2019/12/24
- 新增
diff --git a/pom.xml b/pom.xml
index 81f188ed52a24f4bbdb9acbad7a1b10c0f3dc25d..af082edb92d46ce7e7b0701ad6d2d28fabeece19 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.zhyd.oauth
JustAuth
- 1.14.0-SNAPSHOT
+ 1.14.0
JustAuth
https://gitee.com/yadong.zhang/JustAuth
diff --git a/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java b/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java
index 7446802180f3245e6a336c793c0059312472f13d..3a48641a1fe5f1c539979e62dd0ef3e0535517f8 100644
--- a/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java
+++ b/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java
@@ -725,6 +725,12 @@ public enum AuthDefaultSource implements AuthSource {
}
},
+ /**
+ * 飞书
+ * 注意:该平台暂时存在问题,请不要使用。待修复完成后会重新发版
+ *
+ * @since 1.14.0
+ */
FEISHU{
@Override
public String authorize() {
diff --git a/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java b/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java
index 61cddd6775d2609fedff08186a5a8f2bb02e911c..67b3aaf9cf5e1ebd7af5e25dc13a7e4b9b71266f 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java
@@ -1,9 +1,9 @@
package me.zhyd.oauth.request;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.xkcoding.http.HttpUtil;
+import com.xkcoding.http.support.HttpHeader;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthDefaultSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
@@ -12,28 +12,33 @@ import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
-import me.zhyd.oauth.utils.GlobalAuthUtil;
+import me.zhyd.oauth.utils.GlobalAuthUtils;
import me.zhyd.oauth.utils.UrlBuilder;
/**
+ * 注意:该平台暂时存在问题,请不要使用。待修复完成后会重新发版by yadong.zhang
+ *
* @author beacon
* @since 1.14.0
*/
+@Deprecated
public class AuthFeishuRequest extends AuthDefaultRequest {
public AuthFeishuRequest(AuthConfig config) {
super(config, AuthDefaultSource.FEISHU);
+ throw new AuthException(AuthResponseStatus.FAILURE);
}
@Override
protected AuthToken getAccessToken(AuthCallback authCallback) {
JSONObject requestObject = new JSONObject();
- requestObject.put("app_id",config.getClientId());
- requestObject.put("app_secret",config.getClientSecret());
- requestObject.put("grant_type","authorization_code");
- requestObject.put("code",authCallback.getCode());
- HttpResponse httpResponse = HttpRequest.post(source.accessToken()).body(requestObject.toJSONString(), "application/json").execute();
- JSONObject jsonObject = JSON.parseObject(httpResponse.body());
+ requestObject.put("app_id", config.getClientId());
+ requestObject.put("app_secret", config.getClientSecret());
+ requestObject.put("grant_type", "authorization_code");
+ requestObject.put("code", authCallback.getCode());
+ String response = HttpUtil.post(source.accessToken(), requestObject.toJSONString(), new HttpHeader()
+ .add("Content-Type", "application/json"));
+ JSONObject jsonObject = JSON.parseObject(response);
this.checkResponse(jsonObject);
return AuthToken.builder()
.accessToken(jsonObject.getString("access_token"))
@@ -48,8 +53,10 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
@Override
protected AuthUser getUserInfo(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
- HttpResponse userInfoResponse = HttpRequest.get(source.userInfo()).header("Authorization", "Bearer " + accessToken).execute();
- JSONObject jsonObject = JSON.parseObject(userInfoResponse.body());
+ String response = HttpUtil.get(source.userInfo(), null, new HttpHeader()
+ .add("Content-Type", "application/json")
+ .add("Authorization", "Bearer " + accessToken), false);
+ JSONObject jsonObject = JSON.parseObject(response);
return AuthUser.builder()
.avatar(jsonObject.getString("AvatarUrl"))
.username(jsonObject.getString("Mobile"))
@@ -61,14 +68,13 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
@Override
public AuthResponse refresh(AuthToken authToken) {
JSONObject requestObject = new JSONObject();
- requestObject.put("app_id",config.getClientId());
- requestObject.put("app_secret",config.getClientSecret());
- requestObject.put("grant_type","refresh_token");
- requestObject.put("refresh_token",authToken.getRefreshToken());
- HttpResponse httpResponse = HttpRequest.post(source.refresh())
- .body(requestObject.toJSONString(), "application/json")
- .execute();
- JSONObject jsonObject = JSON.parseObject(httpResponse.body());
+ requestObject.put("app_id", config.getClientId());
+ requestObject.put("app_secret", config.getClientSecret());
+ requestObject.put("grant_type", "refresh_token");
+ requestObject.put("refresh_token", authToken.getRefreshToken());
+ String response = HttpUtil.post(source.refresh(), requestObject.toJSONString(), new HttpHeader()
+ .add("Content-Type", "application/json"));
+ JSONObject jsonObject = JSON.parseObject(response);
this.checkResponse(jsonObject);
return AuthResponse.builder()
.code(AuthResponseStatus.SUCCESS.getCode())
@@ -86,19 +92,20 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
@Override
public String authorize(String state) {
return UrlBuilder.fromBaseUrl(source.authorize())
- .queryParam("app_id",config.getClientId())
- .queryParam("redirect_uri", GlobalAuthUtil.urlEncode(config.getRedirectUri()))
- .queryParam("state",getRealState(state))
+ .queryParam("app_id", config.getClientId())
+ .queryParam("redirect_uri", GlobalAuthUtils.urlEncode(config.getRedirectUri()))
+ .queryParam("state", getRealState(state))
.build();
}
/**
* 校验响应内容是否正确
+ *
* @param jsonObject 响应内容
*/
- private void checkResponse(JSONObject jsonObject){
- if(jsonObject.getIntValue("code") != 0){
+ private void checkResponse(JSONObject jsonObject) {
+ if (jsonObject.getIntValue("code") != 0) {
throw new AuthException(jsonObject.getString("message"));
}
}
diff --git a/src/main/java/me/zhyd/oauth/utils/AuthChecker.java b/src/main/java/me/zhyd/oauth/utils/AuthChecker.java
index 178614c6c8fb9b9041155720c94768f90ccc8f71..be24a5cbb48556f9557b2d44feb8f1f8f66baa7f 100644
--- a/src/main/java/me/zhyd/oauth/utils/AuthChecker.java
+++ b/src/main/java/me/zhyd/oauth/utils/AuthChecker.java
@@ -91,6 +91,7 @@ public class AuthChecker {
* 2. {@code state}为前端伪造,本身就不存在
*
* @param state {@code state}一定不为空
+ * @param source {@code source}当前授权平台
* @param authStateCache {@code authStateCache} state缓存实现
*/
public static void checkState(String state, AuthSource source, AuthStateCache authStateCache) {