Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
justauth
JustAuth
提交
65c60a61
J
JustAuth
项目概览
justauth
/
JustAuth
1 年多 前同步成功
通知
391
Star
15212
Fork
2708
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JustAuth
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
65c60a61
编写于
3月 17, 2020
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔖
发布1.14.0,解耦HTTP工具
上级
d5a8ffca
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
77 addition
and
39 deletion
+77
-39
README.en-US.md
README.en-US.md
+5
-4
README.md
README.md
+4
-4
bin/version.txt
bin/version.txt
+1
-1
docs/README.md
docs/README.md
+2
-2
docs/_coverpage.md
docs/_coverpage.md
+1
-1
docs/_sidebar.md
docs/_sidebar.md
+3
-1
docs/contributors.md
docs/contributors.md
+4
-0
docs/oauth/wechat_mp.md
docs/oauth/wechat_mp.md
+10
-0
docs/oauth/wechat_open.md
docs/oauth/wechat_open.md
+1
-1
docs/update.md
docs/update.md
+7
-0
pom.xml
pom.xml
+1
-1
src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java
src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java
+6
-0
src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java
src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java
+31
-24
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
+1
-0
未找到文件。
README.en-US.md
浏览文件 @
65c60a61
...
...
@@ -6,7 +6,7 @@
</p>
<p
align=
"center"
>
<a
target=
"_blank"
href=
"https://search.maven.org/search?q=JustAuth"
>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
3.2
-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
4.0
-blue.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"
>
<img
src=
"https://img.shields.io/apm/l/vim-mode.svg?color=yellow"
></img>
...
...
@@ -15,7 +15,7 @@
<img
src=
"https://img.shields.io/badge/JDK-1.8+-green.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://apidoc.gitee.com/yadong.zhang/JustAuth/"
title=
"API文档"
>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
3.2
-orange.svg"
></img>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
4.0
-orange.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://docs.justauth.whnb.wang"
title=
"参考文档"
>
<img
src=
"https://img.shields.io/badge/Docs-latest-blueviolet.svg"
></img>
...
...
@@ -44,7 +44,7 @@
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
title=
"微信开放平台
、微信公众平台和微信企业版
"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
title=
"微信开放平台"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png"
width=
"20"
></td>
...
...
@@ -62,6 +62,7 @@
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
title=
"微信企业版"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
></td>
...
...
@@ -96,7 +97,7 @@ These artifacts are available from Maven Central:
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.1
3.2
</version>
<version>
1.1
4.0
</version>
</dependency>
```
-
Using JustAuth
...
...
README.md
浏览文件 @
65c60a61
...
...
@@ -6,7 +6,7 @@
</p>
<p
align=
"center"
>
<a
target=
"_blank"
href=
"https://search.maven.org/search?q=JustAuth"
>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
3.2
-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
4.0
-blue.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"
>
<img
src=
"https://img.shields.io/apm/l/vim-mode.svg?color=yellow"
></img>
...
...
@@ -15,7 +15,7 @@
<img
src=
"https://img.shields.io/badge/JDK-1.8+-green.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://apidoc.gitee.com/yadong.zhang/JustAuth/"
title=
"API文档"
>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
3.2
-orange.svg"
></img>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
4.0
-orange.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://docs.justauth.whnb.wang"
title=
"参考文档"
>
<img
src=
"https://img.shields.io/badge/Docs-latest-blueviolet.svg"
></img>
...
...
@@ -44,7 +44,7 @@
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
title=
"微信开放平台"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png"
width=
"20"
></td>
...
...
@@ -97,7 +97,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.1
3.2
</version>
<version>
1.1
4.0
</version>
</dependency>
```
-
调用api
...
...
bin/version.txt
浏览文件 @
65c60a61
1.1
3.2
1.1
4.0
docs/README.md
浏览文件 @
65c60a61
...
...
@@ -9,7 +9,7 @@
</p>
<p
align=
"center"
>
<a
target=
"_blank"
href=
"https://search.maven.org/search?q=JustAuth"
>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
3.2
-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
4.0
-blue.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"
>
<img
src=
"https://img.shields.io/apm/l/vim-mode.svg?color=yellow"
></img>
...
...
@@ -18,7 +18,7 @@
<img
src=
"https://img.shields.io/badge/JDK-1.8+-green.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://apidoc.gitee.com/yadong.zhang/JustAuth/"
title=
"API文档"
>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
3.2
-orange.svg"
></img>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
4.0
-orange.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://docs.justauth.whnb.wang"
title=
"参考文档"
>
<img
src=
"https://img.shields.io/badge/Docs-latest-blueviolet.svg"
></img>
...
...
docs/_coverpage.md
浏览文件 @
65c60a61
![](
_media/logo.png
)
# JustAuth <small>1.1
3.2
</small>
# JustAuth <small>1.1
4.0
</small>
<strong>
史上最全的整合第三方登录的开源库
</strong>
...
...
docs/_sidebar.md
浏览文件 @
65c60a61
...
...
@@ -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
)
...
...
docs/contributors.md
浏览文件 @
65c60a61
...
...
@@ -26,6 +26,10 @@
-
添加测试用例:UrlBuilder 、GlobalAuthUtil
-
<img
src=
"https://avatars0.githubusercontent.com/u/283483?s=180&v=4"
width=
"20"
>
· Chris Smowton :
<a
href=
"https://github.com/smowton"
target=
"_blank"
>
[Github]
</a>
-
添加测试用例:StringUtils
-
<img
src=
"https://avatars1.githubusercontent.com/u/31759178?s=88&v=4"
width=
"20"
>
· githubeacon :
<a
href=
"https://github.com/githubeacon"
target=
"_blank"
>
[Github]
</a>
-
增加飞书授权登录
-
<img
src=
"https://avatars3.githubusercontent.com/u/20242284?s=88&u=2aeb7576bd61392e9fd94227d2b3048a9aea6f73&v=4"
width=
"20"
>
· runningzyp :
<a
href=
"https://github.com/runningzyp"
target=
"_blank"
>
[Github]
</a>
-
修改文案错误
-
千年等一回,我只为等你...
ps: 如有遗漏,请告知
docs/oauth/wechat_mp.md
0 → 100644
浏览文件 @
65c60a61
(敬请期待...)
### 声明:
此文档适用于
**微信公众平台**
!
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
docs/oauth/wechat_open.md
浏览文件 @
65c60a61
### 声明:
此文档适用于
**微信开放平台**
、
**微信开放平台**
、
**微信开放平台**
,不是
**微信公众平台**
!
此文档适用于
**微信开放平台**
!
## 1. 申请应用
...
...
docs/update.md
浏览文件 @
65c60a61
## 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
-
新增
...
...
pom.xml
浏览文件 @
65c60a61
...
...
@@ -6,7 +6,7 @@
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.14.0
-SNAPSHOT
</version>
<version>
1.14.0
</version>
<name>
JustAuth
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
...
...
src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java
浏览文件 @
65c60a61
...
...
@@ -725,6 +725,12 @@ public enum AuthDefaultSource implements AuthSource {
}
},
/**
* 飞书
* 注意:该平台暂时存在问题,请不要使用。待修复完成后会重新发版
*
* @since 1.14.0
*/
FEISHU
{
@Override
public
String
authorize
()
{
...
...
src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java
浏览文件 @
65c60a61
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.GlobalAuthUtil
s
;
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"
,
GlobalAuthUtil
s
.
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"
));
}
}
...
...
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
浏览文件 @
65c60a61
...
...
@@ -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
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录