Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正在写bug并嘿嘿一笑
JustAuth
提交
c94b123a
J
JustAuth
项目概览
正在写bug并嘿嘿一笑
/
JustAuth
与 Fork 源项目一致
Fork自
justauth / JustAuth
通知
1
Star
1
Fork
0
代码
文件
提交
分支
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c94b123a
编写于
9月 03, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
集成Gitlab
上级
ee1b6c8c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
201 addition
and
49 deletion
+201
-49
README.en-US.md
README.en-US.md
+4
-2
README.md
README.md
+30
-28
docs/README.md
docs/README.md
+28
-8
docs/_sidebar.md
docs/_sidebar.md
+1
-1
docs/how-to-use.md
docs/how-to-use.md
+3
-3
docs/update.md
docs/update.md
+4
-0
pom.xml
pom.xml
+1
-1
src/main/java/me/zhyd/oauth/config/AuthSource.java
src/main/java/me/zhyd/oauth/config/AuthSource.java
+23
-0
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+12
-6
src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
+95
-0
未找到文件。
README.en-US.md
浏览文件 @
c94b123a
...
...
@@ -65,6 +65,7 @@
<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>
</tr>
</table>
</center>
...
...
@@ -92,7 +93,7 @@ These artifacts are available from Maven Central:
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.11.0
</version>
<version>
${latest.version}
</version>
</dependency>
```
-
Using JustAuth
...
...
@@ -147,8 +148,9 @@ authRequest.login(callback);
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png"
width=
"20"
>
|
[
AuthStackOverflowRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java
)
|
<a
href=
"https://api.stackexchange.com/docs/authentication"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png"
width=
"20"
>
|
[
AuthHuaweiRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java
)
|
<a
href=
"https://developer.huawei.com/consumer/cn/devservice/doc/30101"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
>
|
[
AuthWeChatEnterpriseRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java
)
|
<a
href=
"https://open.work.weixin.qq.com/api/doc#90000/90135/90664"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
>
|
[
AuthKujialeRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
)
|
<a
href=
"https://open.kujiale.com/open/apps/2/docs?doc_id=95"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
>
|
[
AuthGitlabRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
)
|
<a
href=
"https://docs.gitlab.com/ee/api/oauth2.html"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
...
...
README.md
浏览文件 @
c94b123a
...
...
@@ -34,37 +34,38 @@
<center>
<table>
<tr>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权gitee"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权github"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权weibo"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权钉钉"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权百度"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权coding"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权腾讯云开发者平台"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/tencentCloud.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权oschina"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权支付宝"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权qq"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权微信"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权淘宝"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权google"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权facebook"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
a
href=
"#授权抖音"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png"
width=
"20"
></a
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/tencentCloud.png"
width=
"20"
></td>
<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/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>
<td
align=
"center"
width=
"200"
><
img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png"
width=
"20"
></td>
</tr>
</table>
<table>
<tr>
<td
align=
"center"
width=
"200"
><a
href=
"#授权领英"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权微软"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权小米"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权今日头条"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/toutiao.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权Teambition"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/teambition.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权人人"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/renren.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权Pinterest"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权Stack Overflow"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权华为"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权微信企业版"
title=
"微信企业版"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权csdn"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><a
href=
"#授权酷家乐"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
></a></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/toutiao.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/teambition.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/renren.png"
width=
"20"
></td>
<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>
</tr>
</table>
</center>
...
...
@@ -157,8 +158,9 @@ authRequest.login(callback);
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png"
width=
"20"
>
|
[
AuthStackOverflowRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java
)
|
<a
href=
"https://api.stackexchange.com/docs/authentication"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png"
width=
"20"
>
|
[
AuthHuaweiRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java
)
|
<a
href=
"https://developer.huawei.com/consumer/cn/devservice/doc/30101"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
>
|
[
AuthWeChatEnterpriseRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java
)
|
<a
href=
"https://open.work.weixin.qq.com/api/doc#90000/90135/90664"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
>
|
[
AuthKujialeRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
)
|
<a
href=
"https://open.kujiale.com/open/apps/2/docs?doc_id=95"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
>
|
[
AuthGitlabRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
)
|
<a
href=
"https://docs.gitlab.com/ee/api/oauth2.html"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
_请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_
...
...
docs/README.md
浏览文件 @
c94b123a
...
...
@@ -89,6 +89,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
>
|
[
AuthWeChatEnterpriseRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java
)
|
<a
href=
"https://open.work.weixin.qq.com/api/doc#90000/90135/90664"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
>
|
[
AuthKujialeRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
)
|
<a
href=
"https://open.kujiale.com/open/apps/2/docs?doc_id=95"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
>
|
[
AuthGitlabRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
)
|
<a
href=
"https://docs.gitlab.com/ee/api/oauth2.html"
target=
"_blank"
>
参考文档
</a>
|
## 快速开始
...
...
@@ -98,7 +99,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.11.0
</version>
<version>
${latest.version}
</version>
</dependency>
```
-
调用api
...
...
@@ -116,18 +117,37 @@ authRequest.authorize("state");
authRequest
.
login
(
callback
);
```
## 贡献代码
## 参与&贡献
JustAuth的发展离不开朋友们的支持,时至今日,JustAuth已渐趋完善,但仍有很大的改善空间。欢迎各位朋友为JustAuth贡献一份力量。
### 提供bug或建议
-
[
Gitee
](
https://gitee.com/yadong.zhang/JustAuth/issues
)
-
[
Github
](
https://github.com/justauth/JustAuth/issues
)
如果你正在使用JustAuth,可以在这儿留下你的足迹,获得优先推送、曝光
-
[
Gitee
](
https://gitee.com/yadong.zhang/JustAuth/issues/IZ2T7
)
-
[
Github
](
https://github.com/justauth/JustAuth/issues/17
)
### 贡献代码的步骤
1.
fork本项目到自己的repo
2.
把fork过去的项目也就是你仓库中的项目clone到你
的
本地
3.
修改代码
4.
commit后push到自己的库
2.
把fork过去的项目也就是你仓库中的项目clone到你本地
3.
修改代码
(
`dev`
分支)
4.
commit后push到自己的
仓
库
5.
发起PR(pull request) 请求,提交到
`dev`
分支
6.
等待作者合并
6.
等待合并
### 注意事项
_注:JustAuth只接受集成oauth2.0的平台_
1.
JustAuth只接受集成
**OAuth2.0**
的平台
2.
建议安装“
**阿里编码规约**
”插件,然后进行开发
3.
提交PR前请格式化好自己的代码
4.
注释规范,自定义的方法一定要加上:方法说明、参数说明、返回值说明等
##
关于
功能尝鲜
## 功能尝鲜
JustAuth一共有两个主要分支:
-
线上版分支(master):稳定版,发布版就是这个分支的代码
...
...
docs/_sidebar.md
浏览文件 @
c94b123a
-
[
概述
](
README.md
)
-
[
入门和使用
](
README.md
)
-
快速开始
-
[
名词解释
](
explain.md
)
-
[
如何使用
](
how-to-use.md
)
...
...
docs/how-to-use.md
浏览文件 @
c94b123a
...
...
@@ -2,10 +2,10 @@
既然牛皮吹下了, 那么如何才能用JustAuth实现第三方登录呢?
使用JustAuth总共分三步(
**这三步也适合于
任何一个支持的
平台**
):
使用JustAuth总共分三步(
**这三步也适合于
JustAuth支持的任何一个
平台**
):
1.
申请注册第三方平台的开发者账号
2.
创建第三方平台的应用,获取配置信息(
id, secret, callbackUrl
)
2.
创建第三方平台的应用,获取配置信息(
`accessKey`
,
`secretKey`
,
`redirectUri`
)
3.
使用该工具实现授权登陆
...
...
@@ -14,7 +14,7 @@
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.11.0
</version>
<version>
${latest.version}
</version>
</dependency>
```
-
调用api
...
...
docs/update.md
浏览文件 @
c94b123a
## v1.11.0
### 2019/09/03
-
集成“Gitlab”授权登录
### 2019/09/02
-
集成“酷家乐”授权登录
...
...
pom.xml
浏览文件 @
c94b123a
...
...
@@ -12,7 +12,7 @@
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
<description>
史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、
QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信
和酷家乐
等第三方平台的授权登录。
QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信
、酷家乐和Gitlab
等第三方平台的授权登录。
Login, so easy!
</description>
...
...
src/main/java/me/zhyd/oauth/config/AuthSource.java
浏览文件 @
c94b123a
...
...
@@ -568,6 +568,7 @@ public enum AuthSource {
return
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo"
;
}
},
/**
* 酷家乐
*
...
...
@@ -593,6 +594,28 @@ public enum AuthSource {
public
String
refresh
()
{
return
"https://oauth.kujiale.com/oauth2/auth/token/refresh"
;
}
},
/**
* Gitlab
*
* @since 1.11.0
*/
GITLAB
{
@Override
public
String
authorize
()
{
return
"https://gitlab.com/oauth/authorize"
;
}
@Override
public
String
accessToken
()
{
return
"https://gitlab.com/oauth/token"
;
}
@Override
public
String
userInfo
()
{
return
"https://gitlab.com/api/v4/user"
;
}
};
/**
...
...
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
浏览文件 @
c94b123a
...
...
@@ -34,9 +34,9 @@ public class AuthGithubRequest extends AuthDefaultRequest {
protected
AuthToken
getAccessToken
(
AuthCallback
authCallback
)
{
HttpResponse
response
=
doPostAuthorizationCode
(
authCallback
.
getCode
());
Map
<
String
,
String
>
res
=
GlobalAuthUtil
.
parseStringToMap
(
response
.
body
());
if
(
res
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
res
.
get
(
"error"
)
+
":"
+
res
.
get
(
"error_description"
));
}
this
.
checkResponse
(
res
.
containsKey
(
"error"
),
res
.
get
(
"error_description"
));
return
AuthToken
.
builder
()
.
accessToken
(
res
.
get
(
"access_token"
))
.
scope
(
res
.
get
(
"scope"
))
...
...
@@ -48,9 +48,9 @@ public class AuthGithubRequest extends AuthDefaultRequest {
protected
AuthUser
getUserInfo
(
AuthToken
authToken
)
{
HttpResponse
response
=
doGetUserInfo
(
authToken
);
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
object
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
object
.
getString
(
"error_description"
));
}
this
.
checkResponse
(
object
.
containsKey
(
"error"
),
object
.
getString
(
"error_description"
));
return
AuthUser
.
builder
()
.
uuid
(
object
.
getString
(
"id"
))
.
username
(
object
.
getString
(
"login"
))
...
...
@@ -67,4 +67,10 @@ public class AuthGithubRequest extends AuthDefaultRequest {
.
build
();
}
private
void
checkResponse
(
boolean
error
,
String
error_description
)
{
if
(
error
)
{
throw
new
AuthException
(
error_description
);
}
}
}
src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
0 → 100644
浏览文件 @
c94b123a
package
me.zhyd.oauth.request
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.cache.AuthStateCache
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.enums.AuthUserGender
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* Gitlab登录
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @since 1.11.0
*/
public
class
AuthGitlabRequest
extends
AuthDefaultRequest
{
public
AuthGitlabRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
GITLAB
);
}
public
AuthGitlabRequest
(
AuthConfig
config
,
AuthStateCache
authStateCache
)
{
super
(
config
,
AuthSource
.
GITLAB
,
authStateCache
);
}
@Override
protected
AuthToken
getAccessToken
(
AuthCallback
authCallback
)
{
HttpResponse
response
=
doPostAuthorizationCode
(
authCallback
.
getCode
());
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
this
.
checkResponse
(
object
);
return
AuthToken
.
builder
()
.
accessToken
(
object
.
getString
(
"access_token"
))
.
refreshToken
(
object
.
getString
(
"refresh_token"
))
.
idToken
(
object
.
getString
(
"id_token"
))
.
tokenType
(
object
.
getString
(
"token_type"
))
.
scope
(
object
.
getString
(
"scope"
))
.
build
();
}
@Override
protected
AuthUser
getUserInfo
(
AuthToken
authToken
)
{
HttpResponse
response
=
doGetUserInfo
(
authToken
);
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
this
.
checkResponse
(
object
);
return
AuthUser
.
builder
()
.
uuid
(
object
.
getString
(
"id"
))
.
username
(
object
.
getString
(
"username"
))
.
nickname
(
object
.
getString
(
"name"
))
.
avatar
(
object
.
getString
(
"avatar_url"
))
.
blog
(
object
.
getString
(
"web_url"
))
.
company
(
object
.
getString
(
"organization"
))
.
location
(
object
.
getString
(
"location"
))
.
email
(
object
.
getString
(
"email"
))
.
remark
(
object
.
getString
(
"bio"
))
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
source
)
.
build
();
}
private
void
checkResponse
(
JSONObject
object
)
{
// oauth/token 验证异常
if
(
object
.
containsKey
(
"error"
))
{
throw
new
AuthException
(
object
.
getString
(
"error_description"
));
}
// user 验证异常
if
(
object
.
containsKey
(
"message"
))
{
throw
new
AuthException
(
object
.
getString
(
"message"
));
}
}
/**
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
*
* @param state state 验证授权流程的参数,可以防止csrf
* @return 返回授权地址
* @since 1.11.0
*/
@Override
public
String
authorize
(
String
state
)
{
return
UrlBuilder
.
fromBaseUrl
(
super
.
authorize
(
state
))
.
queryParam
(
"scope"
,
"read_user+openid+profile+email"
)
.
build
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录