Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2038f24b3b | |||
| f8f13fdb10 | |||
| 697c07cccc | |||
| e868d43ca3 | |||
| 0700d7ee25 | |||
| 822b4806a1 | |||
| ab8c24ee5c | |||
| cd24cbdd58 | |||
| 4bc9c09610 | |||
| 4d2518e21a | |||
| f47dc074e7 | |||
| b7f01549c1 | |||
| 264294caee | |||
| 19ec565004 | |||
| 028924ecbf | |||
| d2d3232501 | |||
| 1206847576 | |||
| 2490c0f1ff | |||
| 2fd7255ad4 | |||
| f7873d71b2 | |||
| 602b1eaf58 | |||
| 7c2bc82814 | |||
| 28b764f0d2 | |||
| 2442661291 | |||
| abb121a57c | |||
| 51603e18ad | |||
| 77c9680333 | |||
| 525c406c92 | |||
| e65d87daa3 | |||
| 8639359f53 | |||
| 9eda5aaf2b | |||
| 9d6ceb3898 | |||
| 7bb9864799 | |||
| 95e4db2315 | |||
| fc4606dad3 | |||
| 31330a366d | |||
| 7364c203ab |
@@ -25,6 +25,11 @@ hs_err_pid*
|
|||||||
# exclude idea files
|
# exclude idea files
|
||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
*.sh
|
bin/codecov.sh
|
||||||
|
bin/deploy.sh
|
||||||
|
bin/docsify-cli.sh
|
||||||
|
bin/push.sh
|
||||||
|
bin/push-dev.sh
|
||||||
|
|
||||||
target
|
target
|
||||||
|
/pom.xml.versionsBackup
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
||||||
<img src="https://img.shields.io/badge/Maven Central-1.13.1-blue.svg" ></img>
|
<img src="https://img.shields.io/badge/Maven Central-1.13.2-blue.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
|
<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>
|
<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>
|
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
||||||
<img src="https://img.shields.io/badge/Api Docs-1.13.1-orange.svg" ></img>
|
<img src="https://img.shields.io/badge/Api Docs-1.13.2-orange.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
||||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
<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/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/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/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/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/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/facebook.png" width="20"></td>
|
||||||
@@ -62,7 +62,6 @@
|
|||||||
<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/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/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/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/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/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>
|
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png" width="20"></td>
|
||||||
@@ -97,7 +96,7 @@ These artifacts are available from Maven Central:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhyd.oauth</groupId>
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
<artifactId>JustAuth</artifactId>
|
<artifactId>JustAuth</artifactId>
|
||||||
<version>1.13.1</version>
|
<version>1.13.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
- Using JustAuth
|
- Using JustAuth
|
||||||
@@ -140,7 +139,9 @@ authRequest.login(callback);
|
|||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信开放平台"> | [AuthWeChatOpenRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
||||||
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信公众平台"> | [AuthWeChatMpRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java) | <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html" target="_blank">参考文档</a> |
|
||||||
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="企业微信"> | [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/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
||||||
@@ -154,7 +155,6 @@ authRequest.login(callback);
|
|||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
||||||
| <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/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/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/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/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/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/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
||||||
<img src="https://img.shields.io/badge/Maven Central-1.13.1-blue.svg" ></img>
|
<img src="https://img.shields.io/badge/Maven Central-1.13.2-blue.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
|
<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>
|
<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>
|
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
||||||
<img src="https://img.shields.io/badge/Api Docs-1.13.1-orange.svg" ></img>
|
<img src="https://img.shields.io/badge/Api Docs-1.13.2-orange.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
||||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||||
@@ -97,7 +97,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhyd.oauth</groupId>
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
<artifactId>JustAuth</artifactId>
|
<artifactId>JustAuth</artifactId>
|
||||||
<version>1.13.1</version>
|
<version>1.13.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
- 调用api
|
- 调用api
|
||||||
@@ -146,7 +146,9 @@ authRequest.login(callback);
|
|||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信开放平台"> | [AuthWeChatOpenRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
||||||
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信公众平台"> | [AuthWeChatMpRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java) | <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html" target="_blank">参考文档</a> |
|
||||||
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="企业微信"> | [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/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
||||||
@@ -160,7 +162,6 @@ authRequest.login(callback);
|
|||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
||||||
| <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/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/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/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/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/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/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
# 参考自 hutool 工具
|
||||||
|
# 此脚本用于每次升级justauth时替换相应位置的版本号
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
pwd=$(pwd)
|
||||||
|
echo "当前路径:$pwd"
|
||||||
|
|
||||||
|
if [ -n "$1" ];then
|
||||||
|
new_version="$1"
|
||||||
|
old_version=`cat $pwd/bin/version.txt`
|
||||||
|
echo "$old_version 替换为新版本 $new_version"
|
||||||
|
else
|
||||||
|
# 参数错误,退出
|
||||||
|
echo "ERROR: 请指定新版本!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -n "$old_version" ]; then
|
||||||
|
echo "ERROR: 旧版本不存在,请确认bin/version.txt中信息正确"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 替换README.md等文件中的版本
|
||||||
|
sed -i "s/${old_version}/${new_version}/g" $pwd/README.md
|
||||||
|
sed -i "s/${old_version}/${new_version}/g" $pwd/README.en-US.md
|
||||||
|
sed -i "s/${old_version}/${new_version}/g" $pwd/docs/README.md
|
||||||
|
sed -i "s/${old_version}/${new_version}/g" $pwd/docs/_coverpage.md
|
||||||
|
|
||||||
|
# 替换pom.xml中的版本
|
||||||
|
sed -i "s/${old_version}/${new_version}/g" $pwd/pom.xml
|
||||||
|
|
||||||
|
# 保留新版本号
|
||||||
|
echo "$new_version" > $pwd/bin/version.txt
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#------------------------------------------------
|
||||||
|
# 参考自 hutool 工具
|
||||||
|
# 升级justauth版本,包括:
|
||||||
|
# 1. 升级pom.xml中的版本号
|
||||||
|
# 2. 替换README.md中的版本号
|
||||||
|
#------------------------------------------------
|
||||||
|
|
||||||
|
if [ ! -n "$1" ]; then
|
||||||
|
echo "ERROR: 新版本不存在,请指定参数1"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 替换所有模块pom.xml中的版本
|
||||||
|
mvn versions:set -DnewVersion=$1
|
||||||
|
|
||||||
|
# 替换其它地方的版本
|
||||||
|
source $(pwd)/bin/repVersion.sh "$1"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1.13.2
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
||||||
<img src="https://img.shields.io/badge/Maven Central-1.13.1-blue.svg" ></img>
|
<img src="https://img.shields.io/badge/Maven Central-1.13.2-blue.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
|
<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>
|
<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>
|
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
||||||
<img src="https://img.shields.io/badge/Api Docs-1.13.1-orange.svg" ></img>
|
<img src="https://img.shields.io/badge/Api Docs-1.13.2-orange.svg" ></img>
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
||||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||||
@@ -63,8 +63,8 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
|||||||
| :computer: 平台 | :coffee: API类 | :page_facing_up: SDK |
|
| :computer: 平台 | :coffee: API类 | :page_facing_up: SDK |
|
||||||
|:------:|:-------:|:-------:|
|
|:------:|:-------:|:-------:|
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png" width="20"> | [AuthGiteeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | <a href="https://gitee.com/api/v5/oauth_doc#list_1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png" width="20"> | [AuthGiteeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | <a href="https://gitee.com/api/v5/oauth_doc#list_1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png" width="20"> | [AuthGithubRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | <a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png" width="20"> | [AuthGithubRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java) | <a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png" width="20"> | [AuthWeiboRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | <a href="https://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png" width="20"> | [AuthWeiboRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java) | <a href="https://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png" width="20"> | [AuthDingTalkRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java) | <a href="https://open-doc.dingtalk.com/microapp/serverapi2/kymkv6" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png" width="20"> | [AuthDingTalkRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java) | <a href="https://open-doc.dingtalk.com/microapp/serverapi2/kymkv6" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png" width="20"> | [AuthBaiduRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java) | <a href="http://developer.baidu.com/wiki/index.php?title=docs/oauth" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png" width="20"> | [AuthBaiduRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java) | <a href="http://developer.baidu.com/wiki/index.php?title=docs/oauth" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png" width="25"> | [AuthCodingRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java) | <a href="https://open.coding.net/references/oauth/" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png" width="25"> | [AuthCodingRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java) | <a href="https://open.coding.net/references/oauth/" target="_blank">参考文档</a> |
|
||||||
@@ -72,7 +72,9 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
|||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信开放平台"> | [AuthWeChatOpenRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
||||||
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信公众平台"> | [AuthWeChatMpRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java) | <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html" target="_blank">参考文档</a> |
|
||||||
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="企业微信"> | [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/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
||||||
@@ -86,7 +88,6 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
|||||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
||||||
| <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/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/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/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/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/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/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
**非常感谢您对JustAuth的关注**,您现在查询的内容,资料库中暂时没有,我们后续会补充上。
|
||||||
|
|
||||||
|
您可能还会需要以下文档:
|
||||||
|
|
||||||
|
- [OAuth的授权流程是什么样的?](https://docs.justauth.whnb.wang/#/oauth)
|
||||||
|
- [如何使用JustAuth?](https://docs.justauth.whnb.wang/#/how-to-use)
|
||||||
|
- [提问与回答?](https://docs.justauth.whnb.wang/#/Q&A)
|
||||||
|
- [如何集成Github?](https://docs.justauth.whnb.wang/#/oauth/github)
|
||||||
|
- [如何集成Gitee?](https://docs.justauth.whnb.wang/#/oauth/gitee)
|
||||||
|
- [如何集成支付宝?](https://docs.justauth.whnb.wang/#/oauth/alipay)
|
||||||
|
- [如何自定义state?](https://docs.justauth.whnb.wang/#/customize-the-state-cache)
|
||||||
|
- [如何自定义接入自己搭建的oauth平台?](https://docs.justauth.whnb.wang/#/customize-the-oauth)
|
||||||
|
- [有哪些配套项目?](https://docs.justauth.whnb.wang/#/supporting)
|
||||||
|
|
||||||
|
### 如果还是没有您想要的内容,您可以:
|
||||||
|
|
||||||
|
1. (建议) 提Issue: 【[github](https://github.com/justauth/JustAuth/issues)】 | 【[gitee](https://gitee.com/yadong.zhang/JustAuth/issues)】
|
||||||
|
2. 本页面底部直接留言
|
||||||
|
3. 关注公众号(公众号会不定期推送相关内容),扫下方二维码关注公众号:
|
||||||
|
|
||||||
|
<img src="https://gitee.com/yadong.zhang/static/raw/master/wx/wechat_account.jpg" width="200" />
|
||||||
|
|
||||||
|
4. 加微信群(群内有各个优秀开源项目的作者和技术大神),微信扫下方二维码后加我好友(**注:一定要备注JustAUth,无备注的一律不加**):
|
||||||
|
|
||||||
|
<img src="https://gitee.com/yadong.zhang/static/raw/master/wx/wx.png" width="170"/>
|
||||||
|
|
||||||
|
5. 加QQ群:QQ搜索`230017570`(该QQ群为JustAuth官方技术讨论群,禁止群内打广告!)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||

|

|
||||||
# JustAuth <small>1.13.1</small>
|
# JustAuth <small>1.13.2</small>
|
||||||
|
|
||||||
<strong>史上最全的整合第三方登录的开源库</strong>
|
<strong>史上最全的整合第三方登录的开源库</strong>
|
||||||
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 377 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 183 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 27 KiB |
@@ -7,17 +7,17 @@
|
|||||||
- [Q&A](Q&A.md)
|
- [Q&A](Q&A.md)
|
||||||
- 集成第三方
|
- 集成第三方
|
||||||
- [√ Gitee登录](oauth/gitee.md)
|
- [√ Gitee登录](oauth/gitee.md)
|
||||||
- [Github登录](oauth/github.md)
|
- [√ Github登录](oauth/github.md)
|
||||||
- [qq登录](oauth/qq.md)
|
- [√ qq登录](oauth/qq.md)
|
||||||
- [微信登录](oauth/wechat.md)
|
- [√ 微信开放平台登录](oauth/wechat_open.md)
|
||||||
- [微博登录](oauth/weibo.md)
|
- [√ 微博登录](oauth/weibo.md)
|
||||||
- [支付宝登录](oauth/alipay.md)
|
- [√ 支付宝登录](oauth/alipay.md)
|
||||||
- [百度登录](oauth/baidu.md)
|
- [百度登录](oauth/baidu.md)
|
||||||
- [Coding登录](oauth/coding.md)
|
- [Coding登录](oauth/coding.md)
|
||||||
- [钉钉登录](oauth/dingtalk.md)
|
- [钉钉登录](oauth/dingtalk.md)
|
||||||
- [开源中国登录](oauth/oschina.md)
|
- [开源中国登录](oauth/oschina.md)
|
||||||
- [淘宝登录](oauth/taobao.md)
|
- [淘宝登录](oauth/taobao.md)
|
||||||
- [腾讯云登录](oauth/tenchentCloud.md)
|
- [腾讯云登录](oauth/tencentCloud.md)
|
||||||
- [Google登录](oauth/google.md)
|
- [Google登录](oauth/google.md)
|
||||||
- [Facebook登录](oauth/facebook.md)
|
- [Facebook登录](oauth/facebook.md)
|
||||||
- [抖音登录](oauth/douyin.md)
|
- [抖音登录](oauth/douyin.md)
|
||||||
|
|||||||
@@ -163,6 +163,6 @@ public Object revokeAuth(@PathVariable("source") String source, @PathVariable("t
|
|||||||
- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo): NutzBoot集成JustAuth的demo by [蛋蛋](https://github.com/EggsBlue)
|
- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo): NutzBoot集成JustAuth的demo by [蛋蛋](https://github.com/EggsBlue)
|
||||||
- [Blade版](https://github.com/justauth/blade-justauth-demo): Blade集成JustAuth的demo
|
- [Blade版](https://github.com/justauth/blade-justauth-demo): Blade集成JustAuth的demo
|
||||||
|
|
||||||
## springboot starter插件
|
## starter插件
|
||||||
- [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter): Spring Boot 集成 JustAuth 的最佳实践 by [xkcoding](https://github.com/xkcoding)
|
- [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter): Spring Boot 集成 JustAuth 的最佳实践 by [xkcoding](https://github.com/xkcoding)
|
||||||
- [justauth-spring-boot-starter-demo](https://github.com/justauth/justauth-spring-boot-starter-demo): Spring Boot 使用 justauth-spring-boot-starter 快速集成 JustAuth by [xkcoding](https://github.com/xkcoding)
|
- [justauth-spring-security-starter](https://github.com/justauth/justauth-spring-security-starter): JustAuth整合Spring security的 starter依赖 by [luoqiz](https://github.com/luoqiz)
|
||||||
|
|||||||
@@ -16,13 +16,18 @@
|
|||||||
|
|
||||||
<link rel="shortcut icon" href="favicon.ico">
|
<link rel="shortcut icon" href="favicon.ico">
|
||||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
||||||
|
<link rel="stylesheet" href="//unpkg.com/gitalk/dist/gitalk.css">
|
||||||
|
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">Please wait...</div>
|
<div data-app id="app">Please wait...</div>
|
||||||
<script>
|
<script>
|
||||||
|
var num = 0;
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
name: '<img src="./_media/cover.png" width="200"><br>Login, so easy',
|
el: '#app',
|
||||||
|
name: 'JustAuth',
|
||||||
|
logo: './_media/cover.png',
|
||||||
search: {
|
search: {
|
||||||
maxAge: 86400000,
|
maxAge: 86400000,
|
||||||
noData: {
|
noData: {
|
||||||
@@ -30,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
paths: 'auto',
|
paths: 'auto',
|
||||||
placeholder: {
|
placeholder: {
|
||||||
'/': '搜索'
|
'/': '输入您的关键词进行搜索'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
repo: 'https://gitee.com/yadong.zhang/JustAuth',
|
repo: 'https://gitee.com/yadong.zhang/JustAuth',
|
||||||
@@ -39,7 +44,9 @@
|
|||||||
subMaxLevel: 2,
|
subMaxLevel: 2,
|
||||||
auto2top: true,
|
auto2top: true,
|
||||||
coverpage: true,
|
coverpage: true,
|
||||||
|
autoHeader: true,
|
||||||
formatUpdated: '{YYYY}/{MM}/{DD} {HH}:{mm}:{ss}',
|
formatUpdated: '{YYYY}/{MM}/{DD} {HH}:{mm}:{ss}',
|
||||||
|
notFoundPage: '_404.md',
|
||||||
plugins: [
|
plugins: [
|
||||||
function (hook, vm) {
|
function (hook, vm) {
|
||||||
var footer = [
|
var footer = [
|
||||||
@@ -58,17 +65,47 @@
|
|||||||
|
|
||||||
return html
|
return html
|
||||||
+ '\n----\n'
|
+ '\n----\n'
|
||||||
+ 'Last modified {docsify-updated} '
|
+ '最后更新时间: {docsify-updated} '
|
||||||
+ editHtml
|
+ editHtml
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
markdown: {
|
||||||
|
renderer: {
|
||||||
|
code: function(code, lang) {
|
||||||
|
if (lang === "mermaid") {
|
||||||
|
return (
|
||||||
|
'<div class="mermaid">' + mermaid.render('mermaid-svg-' + num++, code) + "</div>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this.origin.code.apply(this, arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@7.1.0/dist/mermaid.min.js"></script>
|
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
||||||
|
<script src="//unpkg.com/docsify-copy-code"></script>
|
||||||
|
<script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
||||||
<script>mermaid.initialize({startOnLoad:true});</script>
|
<script>mermaid.initialize({startOnLoad:true});</script>
|
||||||
|
<script src="//unpkg.com/prismjs/components/prism-java.min.js"></script>
|
||||||
|
|
||||||
|
<script src="//unpkg.com/docsify/lib/plugins/gitalk.min.js"></script>
|
||||||
|
<script src="//unpkg.com/gitalk/dist/gitalk.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const gitalk = new Gitalk({
|
||||||
|
clientID: 'e58f172df200e88e266b',
|
||||||
|
clientSecret: 'ee22ce68934616f7de043a950cbdb7d613a03202',
|
||||||
|
repo: 'justauth-talk',
|
||||||
|
owner: 'zhangyd-c',
|
||||||
|
admin: ['zhangyd-c'],
|
||||||
|
id: location.hash,
|
||||||
|
// facebook-like distraction free mode
|
||||||
|
distractionFreeMode: false
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- 百度统计 -->
|
<!-- 百度统计 -->
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
- 网站B:可以理解成 Oschina
|
- 网站B:可以理解成 Oschina
|
||||||
- 第三方C:可以理解成 Github
|
- 第三方C:可以理解成 Github
|
||||||
|
|
||||||
需求:你想通过Github第三方登录Oschina
|
需求:你想通过Github第三方登录Oschina。(_注:下面的内容为流程图,如果您在阅读的时候显示为纯文字,请刷新页面_)
|
||||||
|
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
|
|||||||
@@ -1,7 +1,214 @@
|
|||||||
(敬请期待...)
|
## 1. 配置应用
|
||||||
|
|
||||||
## 1. 申请应用
|
### 1.1 创建应用
|
||||||
|
|
||||||
|
#### 1. 进入支付宝开放平台([open.alipay.com](https://open.alipay.com))并登录
|
||||||
|
#### 2. 点击“进入我的开放平台”
|
||||||
|

|
||||||
|
#### 3. 通过 **开发者中心-网页&移动应用** 进入应用管理列表页
|
||||||
|

|
||||||
|

|
||||||
|
#### 4. 选择创建 **自定义接入** 应用
|
||||||
|

|
||||||
|
#### 5. 填入相关信息确认创建
|
||||||
|

|
||||||
|
#### 6. 进入应用详情后,点击【功能列表】中的【**+添加功能**】按钮,选择【获取会员信息】
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
### 1.2 配置密钥
|
||||||
|
开发者调用接口前需要先生成RSA密钥,RSA密钥包含应用私钥(APP_PRIVATE_KEY)、应用公钥(APP_PUBLIC_KEY)。生成密钥后在开放平台开发者中心进行密钥配置,配置完成后可以获取支付宝公钥(ALIPAY_PUBLIC_KEY)。
|
||||||
|
|
||||||
|
接下来我们要在【应用详情】最下面的【开发设置】中,配置密钥相关的内容
|
||||||
|
#### 1. 接口加签方式
|
||||||
|
此处生成密钥的详细说明可以参考:[生成 RSA 密钥 ](https://docs.open.alipay.com/291/105971/)
|
||||||
|
|
||||||
|
我们这儿简单介绍一种使用“公钥”加签的方式
|
||||||
|
|
||||||
|
a. 首先下载密钥生成工具:[Windows版](https://ideservice.alipay.com/ide/getPluginUrl.htm?clientType=assistant&platform=win&channelType=WEB)(请不要安装在含有空格的目录路径下) | [MAC_OS版](https://ideservice.alipay.com/ide/getPluginUrl.htm?clientType=assistant&platform=mac&channelType=WEB)
|
||||||
|
|
||||||
|
b. 点击 【生成密钥】 后,工具会自动生成商户应用公钥(public key)和应用私钥(private key),如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击工具界面下方的 【打开文件位置】,即可找到生成的公私钥文件,这儿需要注意!
|
||||||
|
|
||||||
|
工具默认打开的是CSR目录,并不是我们生成的密钥的目录,如下图:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
我们只需要往前返回一级目录,就可看到 RSA密钥 文件夹,进入 RSA密钥 目录后就可看到我们刚刚生成的密钥文件,如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
注意:应用私钥需要在JustAuth中配置。
|
||||||
|
|
||||||
|
c. 回到应用详情页面,点击【接口加签方式】后面的【设置】按钮,【加签模式】中选择【公钥】,然后在下方输入框中输入之前生成的【应用公钥2048.txt】文件内容
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
保存设置后,将会生成一份【支付宝公钥】,注意:这个公钥会在OAuth中使用!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
**注意:**
|
||||||
|
|
||||||
|
生成的私钥需**妥善保管,避免遗失,不要泄露**。应用私钥需填写到代码中供签名时使用。应用公钥需提供给支付宝账号管理者上传到支付宝开放平台。
|
||||||
|
|
||||||
|
#### 2. 接口加签方式
|
||||||
|
|
||||||
|
关于IP白名单的配置方式,请参考:[开放平台 IP 白名单接入指南 ](https://docs.open.alipay.com/200/ipwhitelist)
|
||||||
|
|
||||||
|
#### 3. 支付宝网关
|
||||||
|
|
||||||
|
使用默认的即可:https://openapi.alipay.com/gateway.do
|
||||||
|
|
||||||
|
#### 4. 应用网关
|
||||||
|
|
||||||
|
这是选填字段,主要用来接收支付宝的异步通知。请开发者视个人情况选择使用
|
||||||
|
|
||||||
|
#### 5. 授权回调地址
|
||||||
|
|
||||||
|
这是关键内容,JustAuth中需要用到。比如本例配置的回调地址为:https://www.zhyd.me/oauth/callback/alipay
|
||||||
|
|
||||||
|
|
||||||
|
以上步骤比较繁杂,主要需要注意保存的信息为:
|
||||||
|
- 使用【支付宝开放平台开发助手】生成的【应用私钥】(应用私钥2048.txt)
|
||||||
|
- 配置【接口加签方式】时生成的【支付宝公钥】
|
||||||
|
- 授权回调地址
|
||||||
|
- APPID(应用详情左侧应用名称下方有标注)
|
||||||
|
|
||||||
|
### 1.3 应用提交审核
|
||||||
|
|
||||||
|
通过应用详情上方的【提交审核】按钮,将应用提交审核,大约需要1天左右。(ps:本例的应用,我从提交审核到审核完成,大约用了两个小时)
|
||||||
|
|
||||||
## 2. 集成JustAuth
|
## 2. 集成JustAuth
|
||||||
|
|
||||||
## 3. 授权结果
|
|
||||||
|
### 2.1 引入依赖
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
|
<artifactId>JustAuth</artifactId>
|
||||||
|
<version>${latest.version}</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||||
|
|
||||||
|
### 2.2 创建Request
|
||||||
|
|
||||||
|
```java
|
||||||
|
AuthRequest authRequest = new AuthAlipayRequest(AuthConfig.builder()
|
||||||
|
.clientId("APPID")
|
||||||
|
.clientSecret("应用私钥")
|
||||||
|
.alipayPublicKey("支付宝公钥")
|
||||||
|
.redirectUri("https://www.zhyd.me/oauth/callback/alipay")
|
||||||
|
.build());
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.3 生成授权地址
|
||||||
|
|
||||||
|
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||||
|
```java
|
||||||
|
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||||
|
```
|
||||||
|
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||||
|
|
||||||
|
|
||||||
|
### 2.4 以上完整代码如下
|
||||||
|
|
||||||
|
```java
|
||||||
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
|
import me.zhyd.oauth.request.AuthAlipayRequest;
|
||||||
|
import me.zhyd.oauth.request.AuthRequest;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/oauth")
|
||||||
|
public class RestAuthController {
|
||||||
|
|
||||||
|
@RequestMapping("/render")
|
||||||
|
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/callback")
|
||||||
|
public Object login(String code) {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
return authRequest.login(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuthRequest getAuthRequest() {
|
||||||
|
return new AuthAlipayRequest(AuthConfig.builder()
|
||||||
|
.clientId("APPID")
|
||||||
|
.clientSecret("应用私钥")
|
||||||
|
.alipayPublicKey("支付宝公钥")
|
||||||
|
.redirectUri("https://www.zhyd.me/oauth/callback/alipay")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
授权链接访问成功后会看到以下页面内容:
|
||||||
|

|
||||||
|
|
||||||
|
手机扫码后会进去确认页面
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
手机端点击确认后,web端将会跳转到授权认证页面
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击同意授权即可完成支付宝的oauth登录。
|
||||||
|
|
||||||
|
## 3. 授权结果
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 2000,
|
||||||
|
"msg": null,
|
||||||
|
"data": {
|
||||||
|
"uuid": "208xxxxx37",
|
||||||
|
"username": "张",
|
||||||
|
"nickname": "张",
|
||||||
|
"avatar": "https://tfs.alipayobjects.com/images/partner/T1vzlgXj8cXXXXXXXX",
|
||||||
|
"blog": null,
|
||||||
|
"company": null,
|
||||||
|
"location": "北京 北京市",
|
||||||
|
"email": null,
|
||||||
|
"remark": null,
|
||||||
|
"gender": "MALE",
|
||||||
|
"source": "ALIPAY",
|
||||||
|
"token": {
|
||||||
|
"accessToken": "authxxxx2d5b0a182A53",
|
||||||
|
"expireIn": 1296000,
|
||||||
|
"refreshToken": "authuxxxx4c1b0edb2X53",
|
||||||
|
"uid": "208xxxxx37",
|
||||||
|
"openId": null,
|
||||||
|
"accessCode": null,
|
||||||
|
"unionId": null,
|
||||||
|
"scope": null,
|
||||||
|
"tokenType": null,
|
||||||
|
"idToken": null,
|
||||||
|
"macAlgorithm": null,
|
||||||
|
"macKey": null,
|
||||||
|
"code": null,
|
||||||
|
"oauthToken": null,
|
||||||
|
"oauthTokenSecret": null,
|
||||||
|
"userId": null,
|
||||||
|
"screenName": null,
|
||||||
|
"oauthCallbackConfirmed": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -55,7 +55,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
|
|||||||
|
|
||||||
我们可以直接使用以下方式生成第三方平台的授权链接:
|
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||||
```java
|
```java
|
||||||
String authorizeUrl = authRequest.authorize();
|
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||||
```
|
```
|
||||||
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@ String authorizeUrl = authRequest.authorize();
|
|||||||
import me.zhyd.oauth.config.AuthConfig;
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
import me.zhyd.oauth.request.AuthGiteeRequest;
|
import me.zhyd.oauth.request.AuthGiteeRequest;
|
||||||
import me.zhyd.oauth.request.AuthRequest;
|
import me.zhyd.oauth.request.AuthRequest;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -81,7 +82,7 @@ public class RestAuthController {
|
|||||||
@RequestMapping("/render")
|
@RequestMapping("/render")
|
||||||
public void renderAuth(HttpServletResponse response) throws IOException {
|
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||||
AuthRequest authRequest = getAuthRequest();
|
AuthRequest authRequest = getAuthRequest();
|
||||||
response.sendRedirect(authRequest.authorize());
|
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/callback")
|
@RequestMapping("/callback")
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ AuthRequest authRequest = new AuthGithubRequest(AuthConfig.builder()
|
|||||||
|
|
||||||
我们可以直接使用以下方式生成第三方平台的授权链接:
|
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||||
```java
|
```java
|
||||||
String authorizeUrl = authRequest.authorize();
|
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||||
```
|
```
|
||||||
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||||
|
|
||||||
@@ -61,8 +61,9 @@ String authorizeUrl = authRequest.authorize();
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
import me.zhyd.oauth.config.AuthConfig;
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
import me.zhyd.oauth.request.AuthGiteeRequest;
|
import me.zhyd.oauth.request.AuthGithubRequest;
|
||||||
import me.zhyd.oauth.request.AuthRequest;
|
import me.zhyd.oauth.request.AuthRequest;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -78,7 +79,7 @@ public class RestAuthController {
|
|||||||
@RequestMapping("/render")
|
@RequestMapping("/render")
|
||||||
public void renderAuth(HttpServletResponse response) throws IOException {
|
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||||
AuthRequest authRequest = getAuthRequest();
|
AuthRequest authRequest = getAuthRequest();
|
||||||
response.sendRedirect(authRequest.authorize());
|
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/callback")
|
@RequestMapping("/callback")
|
||||||
|
|||||||
@@ -1,7 +1,96 @@
|
|||||||
(敬请期待...)
|
|
||||||
|
|
||||||
## 1. 申请应用
|
## 1. 申请应用
|
||||||
|
|
||||||
|
### 1.登录QQ互联平台
|
||||||
|
https://connect.qq.com/
|
||||||
|
### 2.申请开发者
|
||||||
|
进入“应用管理”页面:[https://connect.qq.com/manage.html#/](https://connect.qq.com/manage.html#/)
|
||||||
|
如果是第一次使用,并且未进行过开发者认证,需要提交一下个人资料,待认证通过后方可创建应用。
|
||||||
|
|
||||||
|
### 3. 添加应用
|
||||||
|
|
||||||
|
依次点击:应用管理 -> 网站应用 -> 创建应用,应用信息提交后,等待审核通过即可
|
||||||
|
|
||||||
|
应用审核通过后如下:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
copy以下三个信息:`App ID`、`App Key`和`网站回调域`。
|
||||||
|
|
||||||
## 2. 集成JustAuth
|
## 2. 集成JustAuth
|
||||||
|
|
||||||
## 3. 授权结果
|
|
||||||
|
### 2.1 引入依赖
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
|
<artifactId>JustAuth</artifactId>
|
||||||
|
<version>${latest.version}</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||||
|
|
||||||
|
### 2.2 创建Request
|
||||||
|
|
||||||
|
```java
|
||||||
|
AuthRequest authRequest = new AuthQqRequest(AuthConfig.builder()
|
||||||
|
.clientId("App ID")
|
||||||
|
.clientSecret("App Key")
|
||||||
|
.redirectUri("网站回调域")
|
||||||
|
.build());
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.3 生成授权地址
|
||||||
|
|
||||||
|
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||||
|
```java
|
||||||
|
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||||
|
```
|
||||||
|
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||||
|
|
||||||
|
|
||||||
|
### 2.4 以上完整代码如下
|
||||||
|
|
||||||
|
```java
|
||||||
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
|
import me.zhyd.oauth.request.AuthQqRequest;
|
||||||
|
import me.zhyd.oauth.request.AuthRequest;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/oauth")
|
||||||
|
public class RestAuthController {
|
||||||
|
|
||||||
|
@RequestMapping("/render")
|
||||||
|
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/callback")
|
||||||
|
public Object login(String code) {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
return authRequest.login(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuthRequest getAuthRequest() {
|
||||||
|
return new AuthQqRequest(AuthConfig.builder()
|
||||||
|
.clientId("App ID")
|
||||||
|
.clientSecret("App Key")
|
||||||
|
.redirectUri("网站回调域")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. 授权结果
|
||||||
|
|
||||||
|
暂无
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
(敬请期待...)
|
|
||||||
|
|
||||||
## 1. 申请应用
|
|
||||||
|
|
||||||
## 2. 集成JustAuth
|
|
||||||
|
|
||||||
## 3. 授权结果
|
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
### 声明:
|
||||||
|
此文档适用于**微信开放平台**、**微信开放平台**、**微信开放平台**,不是**微信公众平台**!
|
||||||
|
|
||||||
|
## 1. 申请应用
|
||||||
|
|
||||||
|
### 1.注册微信开放平台账号
|
||||||
|
[https://open.weixin.qq.com/](https://open.weixin.qq.com/)。如果已有则忽略该步骤,直接进入第二步。
|
||||||
|
### 2. 申请开发者资质认证
|
||||||
|
|
||||||
|
这儿需要重点说明的是, 微信开放平台创建应用,需要申请**开发者资质认证**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
如上图:账号中心->开发者资质认证
|
||||||
|
|
||||||
|
但是微信**不支持**个人开发者认证,必须要企业信息才能提交认证。
|
||||||
|
|
||||||
|
对于个人开发者来说,我们提供三种解决方案:
|
||||||
|
- 用自己公司的信息做认证(请确保合法合规)
|
||||||
|
- 找朋友帮忙认证
|
||||||
|
- 去TB或者其他平台花钱找人认证,这种方式一般支持:短期租、长期认证
|
||||||
|
|
||||||
|
### 3.创建第三方应用
|
||||||
|
|
||||||
|
认证通过后切换到“网站应用”标签页,点击“创建网站应用”按钮
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
创建完成后,就能在“网站应用”列表中看到相关信息
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击“查看”进入应用详情,可以看到 “OAuth三大件”:`Client ID`、`Client Secret`和`Callback URL`。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
**注意:**
|
||||||
|
- “授权回调域”填写对应域名即可。比如我想给我的博客 [https://www.zhyd.me](https://www.zhyd.me) 增加微信第三方登录,那么我在配回调地址时,就只需要填写 `www.zhyd.me`即可,实际我们自己开发程序时, 可以随便配置具体的回调地址,只要确保是在 `www.zhyd.me` 下的地址就行。本例中, 我在程序中配置的回调地址为:`https://www.zhyd.me/oauth/callback/wechat`
|
||||||
|
- 重要的事情说三遍:**一定要确保应用详情页的“接口信息”中的“微信登录”接口的状态为“已获得”!** **一定要确保应用详情页的“接口信息”中的“微信登录”接口的状态为“已获得”!** **一定要确保应用详情页的“接口信息”中的“微信登录”接口的状态为“已获得”!**否则一定会遇到这个问题:[“Scope参数错误或者Scope没有权限”是怎么回事?](../Q&A.md?id=_7scope参数错误或者scope没有权限是怎么回事?)
|
||||||
|
|
||||||
|
|
||||||
|
## 2. 集成JustAuth
|
||||||
|
|
||||||
|
|
||||||
|
### 2.1 引入依赖
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
|
<artifactId>JustAuth</artifactId>
|
||||||
|
<version>${latest.version}</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||||
|
|
||||||
|
### 2.2 创建Request
|
||||||
|
|
||||||
|
```java
|
||||||
|
AuthRequest authRequest = new AuthWeChatRequest(AuthConfig.builder()
|
||||||
|
.clientId("Client ID")
|
||||||
|
.clientSecret("Client Secret")
|
||||||
|
.redirectUri("https://www.zhyd.me/oauth/callback/wechat")
|
||||||
|
.build());
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.3 生成授权地址
|
||||||
|
|
||||||
|
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||||
|
```java
|
||||||
|
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||||
|
```
|
||||||
|
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||||
|
|
||||||
|
|
||||||
|
### 2.4 以上完整代码如下
|
||||||
|
|
||||||
|
```java
|
||||||
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
|
import me.zhyd.oauth.request.AuthWeChatOpenRequest;
|
||||||
|
import me.zhyd.oauth.request.AuthRequest;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/oauth")
|
||||||
|
public class RestAuthController {
|
||||||
|
|
||||||
|
@RequestMapping("/render")
|
||||||
|
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/callback")
|
||||||
|
public Object login(String code) {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
return authRequest.login(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuthRequest getAuthRequest() {
|
||||||
|
return new AuthWeChatOpenRequest(AuthConfig.builder()
|
||||||
|
.clientId("Client ID")
|
||||||
|
.clientSecret("Client Secret")
|
||||||
|
.redirectUri("https://www.zhyd.me/oauth/callback/wechat")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
授权链接访问成功后会看到以下页面内容:
|
||||||
|

|
||||||
|
|
||||||
|
使用手机扫码后,将会进入确认授权页面
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击同意授权即可完成微信的oauth登录。
|
||||||
|
|
||||||
|
## 3. 授权结果
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 2000,
|
||||||
|
"msg": null,
|
||||||
|
"data": {
|
||||||
|
"uuid": "xxxxxxx",
|
||||||
|
"username": "RD",
|
||||||
|
"nickname": "RD",
|
||||||
|
"avatar": "http://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ereNicKErbtBVnraCnzjGia2ZWPSkI9Ok4ScrmkdiacgPN6D5qeYBf3iba2lXknE7YaMMHHRrMW6Op8eQ/132",
|
||||||
|
"blog": null,
|
||||||
|
"company": null,
|
||||||
|
"location": "中国-北京-",
|
||||||
|
"email": null,
|
||||||
|
"remark": null,
|
||||||
|
"gender": "MALE",
|
||||||
|
"source": "WECHAT_OPEN",
|
||||||
|
"token": {
|
||||||
|
"accessToken": "28_Bzvt4UxxxxFElOxxxxgTqIJmSE5LxB2Az7stFqYVnFoIhL7RbevA0Urc",
|
||||||
|
"expireIn": 7200,
|
||||||
|
"refreshToken": "28_vtarjUxxxxfKh0Axxxxe_vy7E62hAYkMJ5M_JT4gMXM7r1kT_SeKAQz8Ojow",
|
||||||
|
"uid": null,
|
||||||
|
"openId": "xxxxxxx",
|
||||||
|
"accessCode": null,
|
||||||
|
"unionId": "xxxxxxx",
|
||||||
|
"scope": null,
|
||||||
|
"tokenType": null,
|
||||||
|
"idToken": null,
|
||||||
|
"macAlgorithm": null,
|
||||||
|
"macKey": null,
|
||||||
|
"code": null,
|
||||||
|
"oauthToken": null,
|
||||||
|
"oauthTokenSecret": null,
|
||||||
|
"userId": null,
|
||||||
|
"screenName": null,
|
||||||
|
"oauthCallbackConfirmed": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -1,7 +1,153 @@
|
|||||||
(敬请期待...)
|
|
||||||
|
|
||||||
## 1. 申请应用
|
## 1. 申请应用
|
||||||
|
|
||||||
|
### 1.注册微博开放平台账号
|
||||||
|
https://open.weibo.com/apps。如果已有则忽略该步骤,直接进入第二步。
|
||||||
|
### 2.创建应用
|
||||||
|
通过顶部菜单栏的【微连接-网站接入】或者直接点击【[网站接入](https://open.weibo.com/connect)】进入网站接入界面
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
点击【立即接入】按钮进入创建应用页面,填入**应用名称**,**应用分类**选择默认的“网页应用”即可
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
创建完成后会自动跳转到应用信息页面,如下图,根据提示完善应用即可
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
注:全部填写完成后,需要提交审核。
|
||||||
|
|
||||||
|
提交审核完成后,将Oauth需要用到的数据copy下来(下面截图取自我已经审核通过的应用):
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
微博平台的OAuth支持revoke操作,所以会有一个【取消授权回调页】配置。
|
||||||
|
|
||||||
## 2. 集成JustAuth
|
## 2. 集成JustAuth
|
||||||
|
|
||||||
## 3. 授权结果
|
|
||||||
|
### 2.1 引入依赖
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
|
<artifactId>JustAuth</artifactId>
|
||||||
|
<version>${latest.version}</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||||
|
|
||||||
|
### 2.2 创建Request
|
||||||
|
|
||||||
|
```java
|
||||||
|
AuthRequest authRequest = new AuthWeiboRequest(AuthConfig.builder()
|
||||||
|
.clientId("App Key")
|
||||||
|
.clientSecret("App Secret")
|
||||||
|
.redirectUri("授权回调页")
|
||||||
|
.build());
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.3 生成授权地址
|
||||||
|
|
||||||
|
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||||
|
```java
|
||||||
|
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||||
|
```
|
||||||
|
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||||
|
|
||||||
|
|
||||||
|
### 2.4 以上完整代码如下
|
||||||
|
|
||||||
|
```java
|
||||||
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
|
import me.zhyd.oauth.request.AuthWeiboRequest;
|
||||||
|
import me.zhyd.oauth.request.AuthRequest;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/oauth")
|
||||||
|
public class RestAuthController {
|
||||||
|
|
||||||
|
@RequestMapping("/render")
|
||||||
|
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/callback")
|
||||||
|
public Object login(String code) {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
return authRequest.login(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/revoke/{token}")
|
||||||
|
public Object revokeAuth(@PathVariable("token") String token) throws IOException {
|
||||||
|
AuthRequest authRequest = getAuthRequest();
|
||||||
|
return authRequest.revoke(AuthToken.builder().accessToken(token).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuthRequest getAuthRequest() {
|
||||||
|
return new AuthWeiboRequest(AuthConfig.builder()
|
||||||
|
.clientId("App Key")
|
||||||
|
.clientSecret("App Secret")
|
||||||
|
.redirectUri("授权回调页")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
授权链接访问成功后会看到以下页面内容:
|
||||||
|

|
||||||
|
|
||||||
|
网页登录或者手机扫码登录并授权第三方应用的登录请求后,将会获取到用户的信息
|
||||||
|
|
||||||
|
## 3. 授权结果
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 2000,
|
||||||
|
"msg": null,
|
||||||
|
"data": {
|
||||||
|
"uuid": "xxxxxxx",
|
||||||
|
"username": "七彩狼丿",
|
||||||
|
"nickname": "七彩狼丿",
|
||||||
|
"avatar": "https://tva3.sinaimg.cn/crop.0.0.1424.1424.50/649b9a6fjw8ezwz4inarqj213k13kwjh.jpg?KID=imgbed,tva&Expires=1577025808&ssig=Q7m4jDuwUt",
|
||||||
|
"blog": "https://www.zhyd.me",
|
||||||
|
"company": null,
|
||||||
|
"location": "北京 朝阳区",
|
||||||
|
"email": null,
|
||||||
|
"remark": "长大了,不得不接受一些事实",
|
||||||
|
"gender": "MALE",
|
||||||
|
"source": "WEIBO",
|
||||||
|
"token": {
|
||||||
|
"accessToken": "2.xxxxxCNUC",
|
||||||
|
"expireIn": 157679999,
|
||||||
|
"refreshToken": null,
|
||||||
|
"uid": "xxxxxxx",
|
||||||
|
"openId": "xxxxxxx",
|
||||||
|
"accessCode": null,
|
||||||
|
"unionId": null,
|
||||||
|
"scope": null,
|
||||||
|
"tokenType": null,
|
||||||
|
"idToken": null,
|
||||||
|
"macAlgorithm": null,
|
||||||
|
"macKey": null,
|
||||||
|
"code": null,
|
||||||
|
"oauthToken": null,
|
||||||
|
"oauthTokenSecret": null,
|
||||||
|
"userId": null,
|
||||||
|
"screenName": null,
|
||||||
|
"oauthCallbackConfirmed": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
**配套Demo**:
|
## 配套Demo
|
||||||
- [simple版](https://github.com/justauth/JustAuth-demo)
|
- [simple版](https://github.com/justauth/JustAuth-demo)
|
||||||
- [jFinal版](https://github.com/xkcoding/jfinal-justauth-demo): Jfinal集成JustAuth的demo by [xkcoding](https://github.com/xkcoding)
|
- [jFinal版](https://github.com/xkcoding/jfinal-justauth-demo): Jfinal集成JustAuth的demo by [xkcoding](https://github.com/xkcoding)
|
||||||
- [ActFramework版](https://github.com/xkcoding/act-justauth-demo): ActFramework 集成 JustAuth 的 demo by [xkcoding](https://github.com/xkcoding)
|
- [ActFramework版](https://github.com/xkcoding/act-justauth-demo): ActFramework 集成 JustAuth 的 demo by [xkcoding](https://github.com/xkcoding)
|
||||||
- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo): NutzBoot集成JustAuth的demo by [蛋蛋](https://github.com/EggsBlue)
|
- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo): NutzBoot集成JustAuth的demo by [蛋蛋](https://github.com/EggsBlue)
|
||||||
- [Blade版](https://github.com/justauth/blade-justauth-demo): Blade集成JustAuth的demo
|
- [Blade版](https://github.com/justauth/blade-justauth-demo): Blade集成JustAuth的demo
|
||||||
|
|
||||||
## 插件
|
## starter插件
|
||||||
- [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter): Spring Boot 集成 JustAuth 的最佳实践 by [xkcoding](https://github.com/xkcoding)
|
- [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter): Spring Boot 集成 JustAuth 的最佳实践 by [xkcoding](https://github.com/xkcoding)
|
||||||
- [justauth-spring-boot-starter-demo](https://github.com/justauth/justauth-spring-boot-starter-demo): Spring Boot 使用 justauth-spring-boot-starter 快速集成 JustAuth by [xkcoding](https://github.com/xkcoding)
|
- [justauth-spring-security-starter](https://github.com/justauth/justauth-spring-security-starter): JustAuth整合Spring security的 starter依赖 by [luoqiz](https://github.com/luoqiz)
|
||||||
|
|
||||||
|
|
||||||
|
### 更多项目请参考: https://github.com/justauth
|
||||||
@@ -1,3 +1,24 @@
|
|||||||
|
## v1.13.2
|
||||||
|
### 2019/12/24
|
||||||
|
- 新增
|
||||||
|
- 增加微信、QQ、支付宝、微博授权登录的帮助文档
|
||||||
|
- 合并[PR#57](https://github.com/justauth/JustAuth/pull/57),增加微信公众号登录 by [@xkcoding](https://github.com/xkcoding)
|
||||||
|
- [帮助文档](https://docs.justauth.whnb.wang)中增加自定义的404页面
|
||||||
|
- [帮助文档](https://docs.justauth.whnb.wang)中增加Gittalk插件
|
||||||
|
- [帮助文档](https://docs.justauth.whnb.wang)中增加Java代码高亮的插件
|
||||||
|
- 增加`AuthUserGender#getWechatRealGender`方法,兼容获取微信平台的用户性别
|
||||||
|
- 修改
|
||||||
|
- 修复抖音登录取值取错层级的问题([issue#I15SIG@Gitee](https://gitee.com/yadong.zhang/JustAuth/issues/I15SIG))
|
||||||
|
- 完善异常提示的逻辑,支持传入Source(平台),发生异常时显示对应的source(平台)
|
||||||
|
- `checkState`方法从`AuthDefaultRequest`中提出到`AuthChecker`中
|
||||||
|
- `AuthResponseStatus`枚举类中增加`ILLEGAL_STATUS`、`REQUIRED_REFRESH_TOKEN`两个枚举值
|
||||||
|
- `AuthSource`接口中增加`getName`方法,用来对外提供实际`source`的字符串值
|
||||||
|
- `AuthWeiboRequest`微博授权登录中实现`revoke`方法,支持手动回收授权
|
||||||
|
- [帮助文档](https://docs.justauth.whnb.wang)中修复[腾讯云登录]链接错误的问题
|
||||||
|
- 升级
|
||||||
|
- 升级相关依赖:lombok@v1.18.10,hutool@5.0.5,fastjson@1.2.62,alipay@4.8.10.ALL([PR#11@Gitee](https://gitee.com/yadong.zhang/JustAuth/pulls/11))
|
||||||
|
|
||||||
|
|
||||||
## v1.13.1
|
## v1.13.1
|
||||||
### 2019/11/12
|
### 2019/11/12
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 参考自 hutool 工具
|
||||||
|
help(){
|
||||||
|
echo "--------------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
echo "usage: ./ja.sh [updv]"
|
||||||
|
echo ""
|
||||||
|
echo "-updv [version num] Update all justauth related versions."
|
||||||
|
echo ""
|
||||||
|
echo "--------------------------------------------------------------------------"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
'updv')
|
||||||
|
bin/updVersion.sh $2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
esac
|
||||||
@@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
<groupId>me.zhyd.oauth</groupId>
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
<artifactId>JustAuth</artifactId>
|
<artifactId>JustAuth</artifactId>
|
||||||
<version>1.13.1</version>
|
<version>1.13.2</version>
|
||||||
|
|
||||||
<name>JustAuth</name>
|
<name>JustAuth</name>
|
||||||
<url>https://gitee.com/yadong.zhang/JustAuth</url>
|
<url>https://gitee.com/yadong.zhang/JustAuth</url>
|
||||||
<description>
|
<description>
|
||||||
史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、
|
史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、
|
||||||
QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、
|
QQ、微信开放平台、微信公众平台、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、
|
||||||
企业微信、酷家乐、Gitlab、美团、饿了么和推特等第三方平台的授权登录。
|
企业微信、酷家乐、Gitlab、美团、饿了么和推特等第三方平台的授权登录。
|
||||||
Login, so easy!
|
Login, so easy!
|
||||||
</description>
|
</description>
|
||||||
@@ -60,11 +60,11 @@
|
|||||||
<maven-surefire-version>2.20</maven-surefire-version>
|
<maven-surefire-version>2.20</maven-surefire-version>
|
||||||
<maven-gpg-version>1.6</maven-gpg-version>
|
<maven-gpg-version>1.6</maven-gpg-version>
|
||||||
<maven.test.skip>false</maven.test.skip>
|
<maven.test.skip>false</maven.test.skip>
|
||||||
<hutool-version>4.6.1</hutool-version>
|
<hutool-version>5.0.7</hutool-version>
|
||||||
<lombok-version>1.18.4</lombok-version>
|
<lombok-version>1.18.10</lombok-version>
|
||||||
<junit-version>4.11</junit-version>
|
<junit-version>4.11</junit-version>
|
||||||
<fastjson-version>1.2.60</fastjson-version>
|
<fastjson-version>1.2.62</fastjson-version>
|
||||||
<alipay-sdk-version>3.7.4.ALL</alipay-sdk-version>
|
<alipay-sdk-version>4.8.10.ALL</alipay-sdk-version>
|
||||||
<jacoco-version>0.8.2</jacoco-version>
|
<jacoco-version>0.8.2</jacoco-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ public enum AuthDefaultSource implements AuthSource {
|
|||||||
public String userInfo() {
|
public String userInfo() {
|
||||||
return "https://api.weibo.com/2/users/show.json";
|
return "https://api.weibo.com/2/users/show.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String revoke() {
|
||||||
|
return "https://api.weibo.com/oauth2/revokeoauth2";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* gitee
|
* gitee
|
||||||
@@ -235,9 +240,9 @@ public enum AuthDefaultSource implements AuthSource {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 微信
|
* 微信开放平台
|
||||||
*/
|
*/
|
||||||
WECHAT {
|
WECHAT_OPEN {
|
||||||
@Override
|
@Override
|
||||||
public String authorize() {
|
public String authorize() {
|
||||||
return "https://open.weixin.qq.com/connect/qrconnect";
|
return "https://open.weixin.qq.com/connect/qrconnect";
|
||||||
@@ -258,6 +263,30 @@ public enum AuthDefaultSource implements AuthSource {
|
|||||||
return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
|
return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 微信公众平台
|
||||||
|
*/
|
||||||
|
WECHAT_MP {
|
||||||
|
@Override
|
||||||
|
public String authorize() {
|
||||||
|
return "https://open.weixin.qq.com/connect/oauth2/authorize";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String accessToken() {
|
||||||
|
return "https://api.weixin.qq.com/sns/oauth2/access_token";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String userInfo() {
|
||||||
|
return "https://api.weixin.qq.com/sns/userinfo";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String refresh() {
|
||||||
|
return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 淘宝
|
* 淘宝
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,4 +61,16 @@ public interface AuthSource {
|
|||||||
default String refresh() {
|
default String refresh() {
|
||||||
throw new AuthException(AuthResponseStatus.UNSUPPORTED);
|
throw new AuthException(AuthResponseStatus.UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Source的字符串名字
|
||||||
|
*
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
default String getName() {
|
||||||
|
if (this instanceof Enum) {
|
||||||
|
return String.valueOf(this);
|
||||||
|
}
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public enum AuthResponseStatus {
|
|||||||
ILLEGAL_REDIRECT_URI(5006, "Illegal redirect uri"),
|
ILLEGAL_REDIRECT_URI(5006, "Illegal redirect uri"),
|
||||||
ILLEGAL_REQUEST(5007, "Illegal request"),
|
ILLEGAL_REQUEST(5007, "Illegal request"),
|
||||||
ILLEGAL_CODE(5008, "Illegal code"),
|
ILLEGAL_CODE(5008, "Illegal code"),
|
||||||
|
ILLEGAL_STATUS(5009, "Illegal state"),
|
||||||
|
REQUIRED_REFRESH_TOKEN(5010, "The refresh token is required; it must not be null"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package me.zhyd.oauth.enums;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import me.zhyd.oauth.utils.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@@ -18,25 +19,41 @@ public enum AuthUserGender {
|
|||||||
* MALE/FAMALE为正常值,通过{@link AuthUserGender#getRealGender(String)}方法获取真实的性别
|
* MALE/FAMALE为正常值,通过{@link AuthUserGender#getRealGender(String)}方法获取真实的性别
|
||||||
* UNKNOWN为容错值,部分平台不会返回用户性别,为了方便统一,使用UNKNOWN标记所有未知或不可测的用户性别信息
|
* UNKNOWN为容错值,部分平台不会返回用户性别,为了方便统一,使用UNKNOWN标记所有未知或不可测的用户性别信息
|
||||||
*/
|
*/
|
||||||
MALE(1, "男"),
|
MALE("1", "男"),
|
||||||
FEMALE(0, "女"),
|
FEMALE("0", "女"),
|
||||||
UNKNOWN(-1, "未知");
|
UNKNOWN("-1", "未知");
|
||||||
|
|
||||||
private int code;
|
private String code;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
public static AuthUserGender getRealGender(String code) {
|
/**
|
||||||
if (code == null) {
|
* 获取用户的实际性别,常规网站
|
||||||
|
*
|
||||||
|
* @param originalGender 用户第三方标注的原始性别
|
||||||
|
* @return 用户性别
|
||||||
|
*/
|
||||||
|
public static AuthUserGender getRealGender(String originalGender) {
|
||||||
|
if (null == originalGender || UNKNOWN.getCode().equals(originalGender)) {
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
String[] males = {"m", "男", "1", "male"};
|
String[] males = {"m", "男", "1", "male"};
|
||||||
if (Arrays.asList(males).contains(code.toLowerCase())) {
|
if (Arrays.asList(males).contains(originalGender.toLowerCase())) {
|
||||||
return MALE;
|
return MALE;
|
||||||
}
|
}
|
||||||
String[] females = {"f", "女", "0", "female"};
|
return FEMALE;
|
||||||
if (Arrays.asList(females).contains(code.toLowerCase())) {
|
}
|
||||||
return FEMALE;
|
|
||||||
|
/**
|
||||||
|
* 获取微信平台用户的实际性别,0表示未定义,1表示男性,2表示女性
|
||||||
|
*
|
||||||
|
* @param originalGender 用户第三方标注的原始性别
|
||||||
|
* @return 用户性别
|
||||||
|
* @since 1.13.2
|
||||||
|
*/
|
||||||
|
public static AuthUserGender getWechatRealGender(String originalGender) {
|
||||||
|
if (StringUtils.isEmpty(originalGender) || "0".equals(originalGender)) {
|
||||||
|
return AuthUserGender.UNKNOWN;
|
||||||
}
|
}
|
||||||
return UNKNOWN;
|
return getRealGender(originalGender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package me.zhyd.oauth.exception;
|
package me.zhyd.oauth.exception;
|
||||||
|
|
||||||
|
import me.zhyd.oauth.config.AuthSource;
|
||||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,6 +18,10 @@ public class AuthException extends RuntimeException {
|
|||||||
this(AuthResponseStatus.FAILURE.getCode(), errorMsg);
|
this(AuthResponseStatus.FAILURE.getCode(), errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AuthException(String errorMsg, AuthSource source) {
|
||||||
|
this(AuthResponseStatus.FAILURE.getCode(), errorMsg, source);
|
||||||
|
}
|
||||||
|
|
||||||
public AuthException(int errorCode, String errorMsg) {
|
public AuthException(int errorCode, String errorMsg) {
|
||||||
super(errorMsg);
|
super(errorMsg);
|
||||||
this.errorCode = errorCode;
|
this.errorCode = errorCode;
|
||||||
@@ -24,7 +29,15 @@ public class AuthException extends RuntimeException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AuthException(AuthResponseStatus status) {
|
public AuthException(AuthResponseStatus status) {
|
||||||
super(status.getMsg());
|
this(status.getCode(), status.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthException(int errorCode, String errorMsg, AuthSource source) {
|
||||||
|
this(errorCode, String.format("%s [%s]", errorMsg, source.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthException(AuthResponseStatus status, AuthSource source) {
|
||||||
|
this(status.getCode(), status.getMsg(), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthException(String message, Throwable cause) {
|
public AuthException(String message, Throwable cause) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package me.zhyd.oauth.model;
|
package me.zhyd.oauth.model;
|
||||||
|
|
||||||
import lombok.Builder;
|
import lombok.*;
|
||||||
import lombok.Getter;
|
|
||||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,6 +12,7 @@ import java.io.Serializable;
|
|||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
@Builder
|
@Builder
|
||||||
public class AuthResponse<T> implements Serializable {
|
public class AuthResponse<T> implements Serializable {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package me.zhyd.oauth.model;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
|||||||
this.source = source;
|
this.source = source;
|
||||||
this.authStateCache = authStateCache;
|
this.authStateCache = authStateCache;
|
||||||
if (!AuthChecker.isSupportedAuth(config, source)) {
|
if (!AuthChecker.isSupportedAuth(config, source)) {
|
||||||
throw new AuthException(AuthResponseStatus.PARAMETER_INCOMPLETE);
|
throw new AuthException(AuthResponseStatus.PARAMETER_INCOMPLETE, source);
|
||||||
}
|
}
|
||||||
// 校验配置合法性
|
// 校验配置合法性
|
||||||
AuthChecker.checkConfig(config, source);
|
AuthChecker.checkConfig(config, source);
|
||||||
@@ -75,7 +75,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
|||||||
public AuthResponse login(AuthCallback authCallback) {
|
public AuthResponse login(AuthCallback authCallback) {
|
||||||
try {
|
try {
|
||||||
AuthChecker.checkCode(source, authCallback);
|
AuthChecker.checkCode(source, authCallback);
|
||||||
this.checkState(authCallback.getState());
|
AuthChecker.checkState(authCallback.getState(), source, authStateCache);
|
||||||
|
|
||||||
AuthToken authToken = this.getAccessToken(authCallback);
|
AuthToken authToken = this.getAccessToken(authCallback);
|
||||||
AuthUser user = this.getUserInfo(authToken);
|
AuthUser user = this.getUserInfo(authToken);
|
||||||
@@ -94,10 +94,15 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
|||||||
*/
|
*/
|
||||||
private AuthResponse responseError(Exception e) {
|
private AuthResponse responseError(Exception e) {
|
||||||
int errorCode = AuthResponseStatus.FAILURE.getCode();
|
int errorCode = AuthResponseStatus.FAILURE.getCode();
|
||||||
|
String errorMsg = e.getMessage();
|
||||||
if (e instanceof AuthException) {
|
if (e instanceof AuthException) {
|
||||||
errorCode = ((AuthException) e).getErrorCode();
|
AuthException authException = ((AuthException) e);
|
||||||
|
errorCode = authException.getErrorCode();
|
||||||
|
if (StringUtils.isNotEmpty(authException.getErrorMsg())) {
|
||||||
|
errorMsg = authException.getErrorMsg();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AuthResponse.builder().code(errorCode).msg(e.getMessage()).build();
|
return AuthResponse.builder().code(errorCode).msg(errorMsg).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,15 +266,4 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
|||||||
return HttpRequest.get(revokeUrl(authToken)).execute();
|
return HttpRequest.get(revokeUrl(authToken)).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验回调传回的state
|
|
||||||
*
|
|
||||||
* @param state {@code state}一定不为空
|
|
||||||
*/
|
|
||||||
protected void checkState(String state) {
|
|
||||||
if (StringUtils.isEmpty(state) || !authStateCache.containsKey(state)) {
|
|
||||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,13 +42,15 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
|
|||||||
HttpResponse response = doGetUserInfo(authToken);
|
HttpResponse response = doGetUserInfo(authToken);
|
||||||
JSONObject userInfoObject = JSONObject.parseObject(response.body());
|
JSONObject userInfoObject = JSONObject.parseObject(response.body());
|
||||||
this.checkResponse(userInfoObject);
|
this.checkResponse(userInfoObject);
|
||||||
|
JSONObject dataObj = userInfoObject.getJSONObject("data");
|
||||||
return AuthUser.builder()
|
return AuthUser.builder()
|
||||||
.uuid(userInfoObject.getString("union_id"))
|
.uuid(dataObj.getString("union_id"))
|
||||||
.username(userInfoObject.getString("nickname"))
|
.username(dataObj.getString("nickname"))
|
||||||
.nickname(userInfoObject.getString("nickname"))
|
.nickname(dataObj.getString("nickname"))
|
||||||
.avatar(userInfoObject.getString("avatar"))
|
.avatar(dataObj.getString("avatar"))
|
||||||
.remark(userInfoObject.getString("description"))
|
.remark(dataObj.getString("description"))
|
||||||
.gender(AuthUserGender.UNKNOWN)
|
.gender(AuthUserGender.getRealGender(dataObj.getString("gender")))
|
||||||
|
.location(String.format("%s %s %s", dataObj.getString("country"), dataObj.getString("province"), dataObj.getString("city")))
|
||||||
.token(authToken)
|
.token(authToken)
|
||||||
.source(source.toString())
|
.source(source.toString())
|
||||||
.build();
|
.build();
|
||||||
@@ -87,12 +89,13 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
|
|||||||
String accessTokenStr = response.body();
|
String accessTokenStr = response.body();
|
||||||
JSONObject object = JSONObject.parseObject(accessTokenStr);
|
JSONObject object = JSONObject.parseObject(accessTokenStr);
|
||||||
this.checkResponse(object);
|
this.checkResponse(object);
|
||||||
|
JSONObject dataObj = object.getJSONObject("data");
|
||||||
return AuthToken.builder()
|
return AuthToken.builder()
|
||||||
.accessToken(object.getString("access_token"))
|
.accessToken(dataObj.getString("access_token"))
|
||||||
.openId(object.getString("open_id"))
|
.openId(dataObj.getString("open_id"))
|
||||||
.expireIn(object.getIntValue("expires_in"))
|
.expireIn(dataObj.getIntValue("expires_in"))
|
||||||
.refreshToken(object.getString("refresh_token"))
|
.refreshToken(dataObj.getString("refresh_token"))
|
||||||
.scope(object.getString("scope"))
|
.scope(dataObj.getString("scope"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
|||||||
public AuthResponse refresh(AuthToken oldToken) {
|
public AuthResponse refresh(AuthToken oldToken) {
|
||||||
String refreshToken = oldToken.getRefreshToken();
|
String refreshToken = oldToken.getRefreshToken();
|
||||||
if (StringUtils.isEmpty(refreshToken)) {
|
if (StringUtils.isEmpty(refreshToken)) {
|
||||||
throw new AuthException(AuthResponseStatus.UNSUPPORTED);
|
throw new AuthException(AuthResponseStatus.REQUIRED_REFRESH_TOKEN, source);
|
||||||
}
|
}
|
||||||
String refreshTokenUrl = refreshTokenUrl(refreshToken);
|
String refreshTokenUrl = refreshTokenUrl(refreshToken);
|
||||||
return AuthResponse.builder()
|
return AuthResponse.builder()
|
||||||
@@ -161,7 +161,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
|||||||
*/
|
*/
|
||||||
private void checkResponse(JSONObject object) {
|
private void checkResponse(JSONObject object) {
|
||||||
if (object.containsKey("error")) {
|
if (object.containsKey("error")) {
|
||||||
throw new AuthException(object.getString("error_description"));
|
throw new AuthException(object.getString("error_description"), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import me.zhyd.oauth.exception.AuthException;
|
|||||||
import me.zhyd.oauth.model.AuthCallback;
|
import me.zhyd.oauth.model.AuthCallback;
|
||||||
import me.zhyd.oauth.model.AuthToken;
|
import me.zhyd.oauth.model.AuthToken;
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
import me.zhyd.oauth.model.AuthUser;
|
||||||
|
import me.zhyd.oauth.utils.StringUtils;
|
||||||
import me.zhyd.oauth.utils.UrlBuilder;
|
import me.zhyd.oauth.utils.UrlBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,14 +58,12 @@ public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
|||||||
|
|
||||||
// 返回 OpenId 或其他,均代表非当前企业用户,不支持
|
// 返回 OpenId 或其他,均代表非当前企业用户,不支持
|
||||||
if (!object.containsKey("UserId")) {
|
if (!object.containsKey("UserId")) {
|
||||||
throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM);
|
throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM, source);
|
||||||
}
|
}
|
||||||
String userId = object.getString("UserId");
|
String userId = object.getString("UserId");
|
||||||
HttpResponse userDetailResponse = getUserDetail(authToken.getAccessToken(), userId);
|
HttpResponse userDetailResponse = getUserDetail(authToken.getAccessToken(), userId);
|
||||||
JSONObject userDetail = this.checkResponse(userDetailResponse);
|
JSONObject userDetail = this.checkResponse(userDetailResponse);
|
||||||
|
|
||||||
String gender = getRealGender(userDetail);
|
|
||||||
|
|
||||||
return AuthUser.builder()
|
return AuthUser.builder()
|
||||||
.username(userDetail.getString("name"))
|
.username(userDetail.getString("name"))
|
||||||
.nickname(userDetail.getString("alias"))
|
.nickname(userDetail.getString("alias"))
|
||||||
@@ -72,7 +71,7 @@ public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
|||||||
.location(userDetail.getString("address"))
|
.location(userDetail.getString("address"))
|
||||||
.email(userDetail.getString("email"))
|
.email(userDetail.getString("email"))
|
||||||
.uuid(userId)
|
.uuid(userId)
|
||||||
.gender(AuthUserGender.getRealGender(gender))
|
.gender(AuthUserGender.getWechatRealGender(userDetail.getString("gender")))
|
||||||
.token(authToken)
|
.token(authToken)
|
||||||
.source(source.toString())
|
.source(source.toString())
|
||||||
.build();
|
.build();
|
||||||
@@ -88,26 +87,12 @@ public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
|||||||
JSONObject object = JSONObject.parseObject(response.body());
|
JSONObject object = JSONObject.parseObject(response.body());
|
||||||
|
|
||||||
if (object.containsKey("errcode") && object.getIntValue("errcode") != 0) {
|
if (object.containsKey("errcode") && object.getIntValue("errcode") != 0) {
|
||||||
throw new AuthException(object.getIntValue("errcode"), object.getString("errmsg"));
|
throw new AuthException(object.getString("errmsg"), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户的实际性别,0表示未定义,1表示男性,2表示女性
|
|
||||||
*
|
|
||||||
* @param userDetail 用户详情
|
|
||||||
* @return 用户性别
|
|
||||||
*/
|
|
||||||
private String getRealGender(JSONObject userDetail) {
|
|
||||||
int gender = userDetail.getIntValue("gender");
|
|
||||||
if (AuthUserGender.MALE.getCode() == gender) {
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
return 2 == gender ? "0" : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
package me.zhyd.oauth.request;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
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.AuthDefaultSource;
|
||||||
|
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||||
|
import me.zhyd.oauth.enums.AuthUserGender;
|
||||||
|
import me.zhyd.oauth.exception.AuthException;
|
||||||
|
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.UrlBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信公众平台登录
|
||||||
|
*
|
||||||
|
* @author yangkai.shen (https://xkcoding.com)
|
||||||
|
* @since 1.1.0
|
||||||
|
*/
|
||||||
|
public class AuthWeChatMpRequest extends AuthDefaultRequest {
|
||||||
|
public AuthWeChatMpRequest(AuthConfig config) {
|
||||||
|
super(config, AuthDefaultSource.WECHAT_MP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthWeChatMpRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||||
|
super(config, AuthDefaultSource.WECHAT_MP, authStateCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信的特殊性,此时返回的信息同时包含 openid 和 access_token
|
||||||
|
*
|
||||||
|
* @param authCallback 回调返回的参数
|
||||||
|
* @return 所有信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||||
|
return this.getToken(accessTokenUrl(authCallback.getCode()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||||
|
String openId = authToken.getOpenId();
|
||||||
|
|
||||||
|
HttpResponse response = doGetUserInfo(authToken);
|
||||||
|
JSONObject object = JSONObject.parseObject(response.body());
|
||||||
|
|
||||||
|
this.checkResponse(object);
|
||||||
|
|
||||||
|
String location = String.format("%s-%s-%s", object.getString("country"), object.getString("province"), object.getString("city"));
|
||||||
|
|
||||||
|
if (object.containsKey("unionid")) {
|
||||||
|
authToken.setUnionId(object.getString("unionid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return AuthUser.builder()
|
||||||
|
.username(object.getString("nickname"))
|
||||||
|
.nickname(object.getString("nickname"))
|
||||||
|
.avatar(object.getString("headimgurl"))
|
||||||
|
.location(location)
|
||||||
|
.uuid(openId)
|
||||||
|
.gender(AuthUserGender.getWechatRealGender(object.getString("sex")))
|
||||||
|
.token(authToken)
|
||||||
|
.source(source.toString())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthResponse refresh(AuthToken oldToken) {
|
||||||
|
return AuthResponse.builder()
|
||||||
|
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||||
|
.data(this.getToken(refreshTokenUrl(oldToken.getRefreshToken())))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查响应内容是否正确
|
||||||
|
*
|
||||||
|
* @param object 请求响应内容
|
||||||
|
*/
|
||||||
|
private void checkResponse(JSONObject object) {
|
||||||
|
if (object.containsKey("errcode")) {
|
||||||
|
throw new AuthException(object.getIntValue("errcode"), object.getString("errmsg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取token,适用于获取access_token和刷新token
|
||||||
|
*
|
||||||
|
* @param accessTokenUrl 实际请求token的地址
|
||||||
|
* @return token对象
|
||||||
|
*/
|
||||||
|
private AuthToken getToken(String accessTokenUrl) {
|
||||||
|
HttpResponse response = HttpRequest.get(accessTokenUrl).execute();
|
||||||
|
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
|
||||||
|
|
||||||
|
this.checkResponse(accessTokenObject);
|
||||||
|
|
||||||
|
return AuthToken.builder()
|
||||||
|
.accessToken(accessTokenObject.getString("access_token"))
|
||||||
|
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||||
|
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||||
|
.openId(accessTokenObject.getString("openid"))
|
||||||
|
.scope(accessTokenObject.getString("scope"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
||||||
|
*
|
||||||
|
* @param state state 验证授权流程的参数,可以防止csrf
|
||||||
|
* @return 返回授权地址
|
||||||
|
* @since 1.9.3
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String authorize(String state) {
|
||||||
|
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||||
|
.queryParam("appid", config.getClientId())
|
||||||
|
.queryParam("redirect_uri", GlobalAuthUtil.urlEncode(config.getRedirectUri()))
|
||||||
|
.queryParam("response_type", "code")
|
||||||
|
.queryParam("scope", "snsapi_userinfo")
|
||||||
|
.queryParam("state", getRealState(state).concat("#wechat_redirect"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回获取accessToken的url
|
||||||
|
*
|
||||||
|
* @param code 授权码
|
||||||
|
* @return 返回获取accessToken的url
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String accessTokenUrl(String code) {
|
||||||
|
return UrlBuilder.fromBaseUrl(source.accessToken())
|
||||||
|
.queryParam("appid", config.getClientId())
|
||||||
|
.queryParam("secret", config.getClientSecret())
|
||||||
|
.queryParam("code", code)
|
||||||
|
.queryParam("grant_type", "authorization_code")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回获取userInfo的url
|
||||||
|
*
|
||||||
|
* @param authToken 用户授权后的token
|
||||||
|
* @return 返回获取userInfo的url
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String userInfoUrl(AuthToken authToken) {
|
||||||
|
return UrlBuilder.fromBaseUrl(source.userInfo())
|
||||||
|
.queryParam("access_token", authToken.getAccessToken())
|
||||||
|
.queryParam("openid", authToken.getOpenId())
|
||||||
|
.queryParam("lang", "zh_CN")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回获取userInfo的url
|
||||||
|
*
|
||||||
|
* @param refreshToken getAccessToken方法返回的refreshToken
|
||||||
|
* @return 返回获取userInfo的url
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String refreshTokenUrl(String refreshToken) {
|
||||||
|
return UrlBuilder.fromBaseUrl(source.refresh())
|
||||||
|
.queryParam("appid", config.getClientId())
|
||||||
|
.queryParam("grant_type", "refresh_token")
|
||||||
|
.queryParam("refresh_token", refreshToken)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,18 +16,18 @@ import me.zhyd.oauth.model.AuthUser;
|
|||||||
import me.zhyd.oauth.utils.UrlBuilder;
|
import me.zhyd.oauth.utils.UrlBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信登录
|
* 微信开放平台登录
|
||||||
*
|
*
|
||||||
* @author yangkai.shen (https://xkcoding.com)
|
* @author yangkai.shen (https://xkcoding.com)
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class AuthWeChatRequest extends AuthDefaultRequest {
|
public class AuthWeChatOpenRequest extends AuthDefaultRequest {
|
||||||
public AuthWeChatRequest(AuthConfig config) {
|
public AuthWeChatOpenRequest(AuthConfig config) {
|
||||||
super(config, AuthDefaultSource.WECHAT);
|
super(config, AuthDefaultSource.WECHAT_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthWeChatRequest(AuthConfig config, AuthStateCache authStateCache) {
|
public AuthWeChatOpenRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||||
super(config, AuthDefaultSource.WECHAT, authStateCache);
|
super(config, AuthDefaultSource.WECHAT_OPEN, authStateCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +62,7 @@ public class AuthWeChatRequest extends AuthDefaultRequest {
|
|||||||
.avatar(object.getString("headimgurl"))
|
.avatar(object.getString("headimgurl"))
|
||||||
.location(location)
|
.location(location)
|
||||||
.uuid(openId)
|
.uuid(openId)
|
||||||
.gender(AuthUserGender.getRealGender(object.getString("sex")))
|
.gender(AuthUserGender.getWechatRealGender(object.getString("sex")))
|
||||||
.token(authToken)
|
.token(authToken)
|
||||||
.source(source.toString())
|
.source(source.toString())
|
||||||
.build();
|
.build();
|
||||||
@@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import me.zhyd.oauth.cache.AuthStateCache;
|
import me.zhyd.oauth.cache.AuthStateCache;
|
||||||
import me.zhyd.oauth.config.AuthConfig;
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||||
|
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||||
import me.zhyd.oauth.enums.AuthUserGender;
|
import me.zhyd.oauth.enums.AuthUserGender;
|
||||||
import me.zhyd.oauth.exception.AuthException;
|
import me.zhyd.oauth.exception.AuthException;
|
||||||
import me.zhyd.oauth.model.AuthCallback;
|
import me.zhyd.oauth.model.AuthCallback;
|
||||||
|
import me.zhyd.oauth.model.AuthResponse;
|
||||||
import me.zhyd.oauth.model.AuthToken;
|
import me.zhyd.oauth.model.AuthToken;
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
import me.zhyd.oauth.model.AuthUser;
|
||||||
import me.zhyd.oauth.utils.IpUtils;
|
import me.zhyd.oauth.utils.IpUtils;
|
||||||
@@ -90,4 +92,16 @@ public class AuthWeiboRequest extends AuthDefaultRequest {
|
|||||||
.queryParam("uid", authToken.getUid())
|
.queryParam("uid", authToken.getUid())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthResponse revoke(AuthToken authToken) {
|
||||||
|
HttpResponse response = doGetRevoke(authToken);
|
||||||
|
JSONObject object = JSONObject.parseObject(response.body());
|
||||||
|
if (object.containsKey("error")) {
|
||||||
|
return AuthResponse.builder().code(AuthResponseStatus.FAILURE.getCode()).msg(object.getString("error")).build();
|
||||||
|
}
|
||||||
|
// 返回 result = true 表示取消授权成功,否则失败
|
||||||
|
AuthResponseStatus status = object.getBooleanValue("result") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;
|
||||||
|
return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package me.zhyd.oauth.utils;
|
package me.zhyd.oauth.utils;
|
||||||
|
|
||||||
|
import me.zhyd.oauth.cache.AuthStateCache;
|
||||||
import me.zhyd.oauth.config.AuthConfig;
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||||
import me.zhyd.oauth.config.AuthSource;
|
import me.zhyd.oauth.config.AuthSource;
|
||||||
@@ -31,7 +32,7 @@ public class AuthChecker {
|
|||||||
if (isSupported && AuthDefaultSource.STACK_OVERFLOW == source) {
|
if (isSupported && AuthDefaultSource.STACK_OVERFLOW == source) {
|
||||||
isSupported = StringUtils.isNotEmpty(config.getStackOverflowKey());
|
isSupported = StringUtils.isNotEmpty(config.getStackOverflowKey());
|
||||||
}
|
}
|
||||||
if (isSupported && AuthDefaultSource.WECHAT_ENTERPRISE == source){
|
if (isSupported && AuthDefaultSource.WECHAT_ENTERPRISE == source) {
|
||||||
isSupported = StringUtils.isNotEmpty(config.getAgentId());
|
isSupported = StringUtils.isNotEmpty(config.getAgentId());
|
||||||
}
|
}
|
||||||
return isSupported;
|
return isSupported;
|
||||||
@@ -47,15 +48,17 @@ public class AuthChecker {
|
|||||||
public static void checkConfig(AuthConfig config, AuthSource source) {
|
public static void checkConfig(AuthConfig config, AuthSource source) {
|
||||||
String redirectUri = config.getRedirectUri();
|
String redirectUri = config.getRedirectUri();
|
||||||
if (!GlobalAuthUtil.isHttpProtocol(redirectUri) && !GlobalAuthUtil.isHttpsProtocol(redirectUri)) {
|
if (!GlobalAuthUtil.isHttpProtocol(redirectUri) && !GlobalAuthUtil.isHttpsProtocol(redirectUri)) {
|
||||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI);
|
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);
|
||||||
}
|
}
|
||||||
// facebook的回调地址必须为https的链接
|
// facebook的回调地址必须为https的链接
|
||||||
if (AuthDefaultSource.FACEBOOK == source && !GlobalAuthUtil.isHttpsProtocol(redirectUri)) {
|
if (AuthDefaultSource.FACEBOOK == source && !GlobalAuthUtil.isHttpsProtocol(redirectUri)) {
|
||||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI);
|
// Facebook's redirect uri must use the HTTPS protocol
|
||||||
|
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);
|
||||||
}
|
}
|
||||||
// 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1
|
// 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1
|
||||||
if (AuthDefaultSource.ALIPAY == source && GlobalAuthUtil.isLocalHost(redirectUri)) {
|
if (AuthDefaultSource.ALIPAY == source && GlobalAuthUtil.isLocalHost(redirectUri)) {
|
||||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI);
|
// The redirect uri of alipay is forbidden to use localhost or 127.0.0.1
|
||||||
|
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +79,23 @@ public class AuthChecker {
|
|||||||
code = callback.getAuthorization_code();
|
code = callback.getAuthorization_code();
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(code)) {
|
if (StringUtils.isEmpty(code)) {
|
||||||
throw new AuthException(AuthResponseStatus.ILLEGAL_CODE);
|
throw new AuthException(AuthResponseStatus.ILLEGAL_CODE, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验回调传回的{@code state},为空或者不存在
|
||||||
|
* <p>
|
||||||
|
* {@code state}不存在的情况只有两种:
|
||||||
|
* 1. {@code state}已使用,被正常清除
|
||||||
|
* 2. {@code state}为前端伪造,本身就不存在
|
||||||
|
*
|
||||||
|
* @param state {@code state}一定不为空
|
||||||
|
* @param authStateCache {@code authStateCache} state缓存实现
|
||||||
|
*/
|
||||||
|
public static void checkState(String state, AuthSource source, AuthStateCache authStateCache) {
|
||||||
|
if (StringUtils.isEmpty(state) || !authStateCache.containsKey(state)) {
|
||||||
|
throw new AuthException(AuthResponseStatus.ILLEGAL_STATUS, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package me.zhyd.oauth.utils;
|
|||||||
|
|
||||||
import me.zhyd.oauth.config.AuthConfig;
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||||
import me.zhyd.oauth.request.AuthWeChatRequest;
|
import me.zhyd.oauth.request.AuthWeChatOpenRequest;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ public class UrlBuilderTest {
|
|||||||
.clientSecret("secret-110110110")
|
.clientSecret("secret-110110110")
|
||||||
.redirectUri("https://xkcoding.com")
|
.redirectUri("https://xkcoding.com")
|
||||||
.build();
|
.build();
|
||||||
String build = UrlBuilder.fromBaseUrl(AuthDefaultSource.WECHAT.authorize())
|
String build = UrlBuilder.fromBaseUrl(AuthDefaultSource.WECHAT_OPEN.authorize())
|
||||||
.queryParam("appid", config.getClientId())
|
.queryParam("appid", config.getClientId())
|
||||||
.queryParam("redirect_uri", config.getRedirectUri())
|
.queryParam("redirect_uri", config.getRedirectUri())
|
||||||
.queryParam("response_type", "code")
|
.queryParam("response_type", "code")
|
||||||
@@ -30,7 +30,7 @@ public class UrlBuilderTest {
|
|||||||
.queryParam("state", "")
|
.queryParam("state", "")
|
||||||
.build(false);
|
.build(false);
|
||||||
System.out.println(build);
|
System.out.println(build);
|
||||||
AuthWeChatRequest request = new AuthWeChatRequest(config);
|
AuthWeChatOpenRequest request = new AuthWeChatOpenRequest(config);
|
||||||
String authorize = request.authorize("state");
|
String authorize = request.authorize("state");
|
||||||
System.out.println(authorize);
|
System.out.println(authorize);
|
||||||
}
|
}
|
||||||
|
|||||||