提交 4e0fe3ba 编写于 作者: 智布道's avatar 智布道 👁

📝 补充文档:自定义state缓存、自定义实现oauth等

上级 9f341389
......@@ -18,9 +18,12 @@
- [ ] 否,还没做测试,需要作者自测
注:测试demo可以使用:
- [Springboot](https://github.com/justauth/JustAuth-demo)
- [simple](https://github.com/justauth/JustAuth-demo)
- [jFinal版](https://github.com/xkcoding/jfinal-justauth-demo)
- [ActFramework版](https://github.com/xkcoding/act-justauth-demo)
- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo)
- [Blade版](https://github.com/justauth/blade-justauth-demo)
......@@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.12.0-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.13.0-blue.svg" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
......@@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.12.0-orange.svg" ></img>
<img src="https://img.shields.io/badge/Api Docs-1.13.0-orange.svg" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
......@@ -68,6 +68,7 @@
<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/meituan.png" width="20"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/eleme.png" width="20"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/twitter.png" width="20"></td>
</tr>
</table>
<table>
......@@ -100,7 +101,7 @@ These artifacts are available from Maven Central:
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>${latest.version}</version>
<version>1.13.0</version>
</dependency>
```
- Using JustAuth
......@@ -162,7 +163,7 @@ authRequest.login(callback);
| <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/eleme.png" width="20"> | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | <a href="https://open.shop.ele.me/openapi/documents/khd001" target="_blank">参考文档</a> |
| <img src="" width="20"> | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | <a href="https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/twitter.png" width="20"> | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | <a href="https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
......
......@@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.12.0-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.13.0-blue.svg" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
......@@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.12.0-orange.svg" ></img>
<img src="https://img.shields.io/badge/Api Docs-1.13.0-orange.svg" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
......@@ -68,6 +68,7 @@
<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/meituan.png" width="20"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/eleme.png" width="20"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/twitter.png" width="20"></td>
</tr>
</table>
<table>
......@@ -100,7 +101,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.12.0</version>
<version>1.13.0</version>
</dependency>
```
- 调用api
......@@ -119,7 +120,7 @@ authRequest.login(callback);
```
**配套Demo**
- [Springboot版](https://github.com/justauth/JustAuth-demo)
- [JustAuth-demo](https://github.com/justauth/JustAuth-demo)
- [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)
- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo): NutzBoot集成JustAuth的demo by [蛋蛋](https://github.com/EggsBlue)
......@@ -168,7 +169,7 @@ authRequest.login(callback);
| <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/eleme.png" width="20"> | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | <a href="https://open.shop.ele.me/openapi/documents/khd001" target="_blank">参考文档</a> |
| <img src="" width="20"> | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | <a href="https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/twitter.png" width="20"> | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | <a href="https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
_请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_
......
## ~~升级到1.8.0后如何启用state?~~
## 1.项目编译报错
**问题描述**
在使用JustAuth时,`AuthConfig.builder()`报错,提示没有`builder()`方法
**解决方案:**
安装完lombok插件即可
[eclipse安装lombok](https://www.zhyd.me/article/61)
**idea安装lombok:** file->settings->plugins->Browse Repositories->输入`lombok`,点击搜索->选中lombok点击install->安装完成后重启idea
**进阶版问题:**
idea中安装完lombok并重启idea之后,启动项目仍然报错:
![输入图片说明](https://gitee.com/uploads/images/2018/0522/153610_ffe84828_784199.png "1.png")
**解决办法**
![输入图片说明](https://gitee.com/uploads/images/2018/0522/153715_75193de5_784199.jpeg "2.jpg")
默认是eclipse 选择javac就可以了
## 2.~~升级到1.8.0后如何启用state?~~
~~在原api使用方法的基础上,为config追加一个state即可。~~
```
......@@ -10,7 +31,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.build());
```
## ~~升级到1.8.0后login方法报错?~~
## 3.~~升级到1.8.0后login方法报错?~~
~~这是因为1.8.0版本中新增了[AuthCallback](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/model/AuthCallback.java)类,这个类封装了所有可能的回调参数。目前包含以下三个参数:~~
- ~~`code`: 访问AuthorizeUrl后回调时带的参数code,用来换取token~~
......@@ -30,7 +51,7 @@ public Object login(@PathVariable("source") String source, AuthCallback callback
```
~~_代码截取自_ :https://github.com/justauth/JustAuth-demo~~
## ~~升级到1.8.0后对于state参数有什么特殊要求吗?~~
## 4.~~升级到1.8.0后对于state参数有什么特殊要求吗?~~
~~理论上没有,stata只是用来保持会话状态,因为http协议的无状态性,从授权到回调,无法感知具体是哪个用户触发的。所以可以使用state作为校验。注:state参数每次完整的授权链中只可用一次!(也是为了防止不必要的危险)~~
......@@ -42,7 +63,7 @@ public Object login(@PathVariable("source") String source, AuthCallback callback
~~注:`authorize``login`(不是指回调传回的`state`,而是声明`request`时传入的`state`)中传的`state`务必保证一致~~
## 升级到1.9.3+版本后编译失败
## 5.升级到1.9.3+版本后编译失败
主要明显的就是`IpUtils.getIp`和request的`.state`报错。
......@@ -64,7 +85,7 @@ public Object login(@PathVariable("source") String source, AuthCallback callback
}
```
## 升级到最新版本后为什么支付宝登录不能用了?
## 6.升级到最新版本后为什么支付宝登录不能用了?
在升级到新版后,使用支付宝登录会提示`ClassNotFoundExcption`异常,这是因为从`1.9.4`版本开始,JustAuth将不在强依赖`alipay-sdk-java`,如果你需要用到Alipay的授权登陆,那么你还需要添加以下依赖:
......@@ -75,3 +96,45 @@ public Object login(@PathVariable("source") String source, AuthCallback callback
<version>3.7.4.ALL</version>
</dependency>
```
## 7.“Scope参数错误或者Scope没有权限”是怎么回事?
微信开放平台授权登录提示“Scope参数错误或者Scope没有权限”
![Scope参数错误或者Scope没有权限](./_media/scope_error.png)
解决办法:请检查微信开放平台的应用是否有“微信登录”接口的权限。
![“微信登录”接口](./_media/scope_error2.png)
“接口状态”必须为“已获得”!
## 8.微信登录时能在微信端提示登录成功吗?
不可以,这是**微信公众平台**的功能,截至到目前(JustAuth v1.12.0)为止,暂不支持**微信公众平台**的授权登录
## 9.微信登录时能不需要手机确认吗?扫码后就自动登录
不可以,微信开放平台不支持这种操作。可以把微信扫码登录理解成qq用账号密码登录,扫完码后不手动点确认,微信怎么知道用户是否同意了授权?
当然,**微信公众平台**的授权流程可以越过这个限制,只要关注了公众号,后续扫码成功后就会自动登录,但是这是**微信公众平台**的功能,截至到目前(JustAuth v1.12.0)为止,暂不支持**微信公众平台**的授权登录
## 10.本地如何测那些*不支持本地地址回调*的授权登录?
推荐几种方案:
1.`hosts`,然后将测试程序的端口改为`80`
2. 使用`Nginx`/`Apache`做代理
3. FRP内网穿透,参考地址:[使用内网穿透的方式集成第三方登录](https://xkcoding.com/2019/05/22/spring-boot-login-with-oauth.html)
## 11.如何获取QQ登录的`unionId`?
在AuthConfig中设备`unionId``true`
```java
AuthRequest authRequest = new AuthQqRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.unionId(true)
.build());
```
> 注:使用unionId要求开发者必须已在qq开放平台申请了获取unionId的权限,否则可能会发生错误!切记!参考链接:[unionid介绍](http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D)
\ No newline at end of file
......@@ -9,7 +9,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.12.0-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.13.0-blue.svg" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
......@@ -18,7 +18,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.12.0-orange.svg" ></img>
<img src="https://img.shields.io/badge/Api Docs-1.13.0-orange.svg" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
......@@ -91,6 +91,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
| <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/eleme.png" width="20"> | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | <a href="https://open.shop.ele.me/openapi/documents/khd001" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/twitter.png" width="20"> | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | <a href="https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
......
![](_media/logo.png)
# JustAuth <small>1.12.0</small>
# JustAuth <small>1.13.0</small>
<strong>史上最全的整合第三方登录的开源库</strong>
......
......@@ -4,11 +4,43 @@
- [名词解释](explain.md)
- [OAuth流程](oauth.md)
- [如何使用](how-to-use.md)
- 其他特性
- [Q&A](Q&A.md)
- 集成第三方
- [Gitee登录](oauth/gitee.md)
- [Github登录](oauth/github.md)
- [qq登录](oauth/qq.md)
- [微信登录](oauth/wechat.md)
- [微博登录](oauth/weibo.md)
- [支付宝登录](oauth/alipay.md)
- [百度登录](oauth/baidu.md)
- [Coding登录](oauth/coding.md)
- [钉钉登录](oauth/dingtalk.md)
- [开源中国登录](oauth/oschina.md)
- [淘宝登录](oauth/taobao.md)
- [腾讯云登录](oauth/tenchentCloud.md)
- [Google登录](oauth/google.md)
- [Facebook登录](oauth/facebook.md)
- [抖音登录](oauth/douyin.md)
- [领英登录](oauth/linkedin.md)
- [微软登录](oauth/microsoft.md)
- [小米登录](oauth/mi.md)
- [头条登录](oauth/toutiao.md)
- [Teambition登录](oauth/teambition.md)
- [人人登录](oauth/renren.md)
- [Pinterest登录](oauth/pinterest.md)
- [Stackoverflow登录](oauth/stackoverflow.md)
- [华为登录](oauth/huawei.md)
- [微信企业版登录](oauth/wechatEnterprise.md)
- [酷家乐登录](oauth/kujiale.md)
- [Gitlab登录](oauth/gitlab.md)
- [美团登录](oauth/meituan.md)
- [饿了么登录](oauth/eleme.md)
- [CSDN登录](oauth/csdn.md)
- 高级特性
- [使用State](using-state.md)
- [自定义state缓存](customize-the-state-cache.md)
- [自定义第三方平台的OAuth](customize-the-oauth.md)
- [配套项目](supporting.md)
- [Q&A](Q&A.md)
- [Who is using](users.md)
- [致谢](thx.md)
- [更新记录](update.md)
......@@ -10,7 +10,7 @@
- 提供ActFramework版demo
- 提供SpringBoot快速集成的justauth-spring-boot-starter
- <img src="https://avatars2.githubusercontent.com/u/2988765?s=115&v=4" width="20"> · pengisgood : <a href="https://github.com/pengisgood" target="_blank">[Github]</a> | <a href="https://pengisgood.github.io" target="_blank">[个人网站]</a>
- 集成人人登录、Pinterest登录、StackOverflow登录
- 集成人人登录、Pinterest登录、StackOverflow登录、Twitter登录
- <img src="https://avatar.gitee.com/uploads/51/1651_dolphinboy.png!avatar100?1479346570" width="20"> · skqing : <a href="https://gitee.com/skqing" target="_blank">[Gitee]</a> | <a href="https://my.oschina.net/dolphinboy" target="_blank">[个人网站]</a>
- 修复钉钉登录的部分问题
- 优化微博登录
......
# 自定义第三方平台的OAuth
[JustAuth](https://github.com/justauth/JustAuth)发展到现在,基本上已经涵盖了国内外大多数知名的网站。[JustAuth](https://github.com/justauth/JustAuth)也一直以它的**全****简**,备受各位朋友的厚爱、支持。
但现在OAuth技术越来越成熟,越来越多的个人站长或者企业都开始搭建自己的OAuth授权平台,那么针对这种情况,[JustAuth](https://github.com/justauth/JustAuth)并不能做到面面俱到,无法去集成所有支持OAuth的网站(这也是不现实的)。
既然考虑到有这种需求,那么就要想办法解决,想办法填补漏洞,不为了自己,也为了陪伴[JustAuth](https://github.com/justauth/JustAuth)一路走来的所有朋友们。
[JustAuth](https://github.com/justauth/JustAuth)开发团队也在[v1.12.0](https://github.com/justauth/JustAuth/releases/tag/v1.12.0)版本中新加入了一大特性,就是可以支持任意支持OAuth的网站通过JustAuth实现便捷的OAuth登录!
下面我们会通过一个小例子,讲解如何使用JustAuth集成自己搭建的GitLab服务。
> 注:本节将会使用[JustAuth-demo](https://github.com/justauth/JustAuth-demo)Demo项目进行演示
## 搭建Gitlab服务
请自行解决,如果已有搭建好的Gitlab私服,请直接进入下面的步骤
## 创建应用
![gitlab私服创建应用](./_media/custom/gitlab.png)
![gitlab私服应用详情](./_media/custom/gitlab2.png)
## 实现AuthSource接口
`AuthSource.java`是为了提供OAuth平台的API地址的统一接口,提供以下方法供实现:
- `AuthSource#authorize()`: 获取授权url. 必须实现
- `AuthSource#accessToken()`: 获取accessToken的url. 必须实现
- `AuthSource#userInfo()`: 获取用户信息的url. 必须实现
- `AuthSource#revoke()`: 获取取消授权的url. 非必须实现接口(部分平台不支持)
- `AuthSource#refresh()`: 获取刷新授权的url. 非必须实现接口(部分平台不支持)
**注:**
- 当通过JustAuth扩展实现第三方授权时,请参考`AuthDefaultSource`自行创建对应的枚举类并实现`AuthSource`接口
- 如果不是使用的枚举类,那么在授权成功后获取用户信息时,需要**单独处理source字段**的赋值
- 如果扩展了对应枚举类时,在`me.zhyd.oauth.request.AuthRequest#login(AuthCallback)`中可以通过`xx.toString()`获取对应的source
```java
package me.zhyd.justauth;
import me.zhyd.oauth.config.AuthSource;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/10/26 16:54
* @since 1.8
*/
public enum AuthCustomSource implements AuthSource {
/**
* 自己搭建的gitlab私服
*/
MYGITLAB {
/**
* 授权的api
*
* @return url
*/
@Override
public String authorize() {
return "http://gitlab.xxx.com/oauth/authorize";
}
/**
* 获取accessToken的api
*
* @return url
*/
@Override
public String accessToken() {
return "http://gitlab.xxx.com/oauth/token";
}
/**
* 获取用户信息的api
*
* @return url
*/
@Override
public String userInfo() {
return "http://gitlab.xxx.com/api/v4/user";
}
}
}
```
## 创建自定义的Request
```java
package me.zhyd.justauth;
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.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthDefaultRequest;
import me.zhyd.oauth.utils.UrlBuilder;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/10/26 17:00
* @since 1.8
*/
public class AuthMyGitlabRequest extends AuthDefaultRequest {
public AuthMyGitlabRequest(AuthConfig config) {
super(config, AuthCustomSource.MYGITLAB);
}
public AuthMyGitlabRequest(AuthConfig config, AuthStateCache authStateCache) {
super(config, AuthCustomSource.MYGITLAB, authStateCache);
}
@Override
protected AuthToken getAccessToken(AuthCallback authCallback) {
HttpResponse response = doPostAuthorizationCode(authCallback.getCode());
JSONObject object = JSONObject.parseObject(response.body());
this.checkResponse(object);
return AuthToken.builder()
.accessToken(object.getString("access_token"))
.refreshToken(object.getString("refresh_token"))
.idToken(object.getString("id_token"))
.tokenType(object.getString("token_type"))
.scope(object.getString("scope"))
.build();
}
@Override
protected AuthUser getUserInfo(AuthToken authToken) {
HttpResponse response = doGetUserInfo(authToken);
JSONObject object = JSONObject.parseObject(response.body());
this.checkResponse(object);
return AuthUser.builder()
.uuid(object.getString("id"))
.username(object.getString("username"))
.nickname(object.getString("name"))
.avatar(object.getString("avatar_url"))
.blog(object.getString("web_url"))
.company(object.getString("organization"))
.location(object.getString("location"))
.email(object.getString("email"))
.remark(object.getString("bio"))
.gender(AuthUserGender.UNKNOWN)
.token(authToken)
.source(source.toString())
.build();
}
private void checkResponse(JSONObject object) {
// oauth/token 验证异常
if (object.containsKey("error")) {
throw new AuthException(object.getString("error_description"));
}
// user 验证异常
if (object.containsKey("message")) {
throw new AuthException(object.getString("message"));
}
}
/**
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
*
* @param state state 验证授权流程的参数,可以防止csrf
* @return 返回授权地址
* @since 1.11.0
*/
@Override
public String authorize(String state) {
return UrlBuilder.fromBaseUrl(super.authorize(state))
.queryParam("scope", "read_user+openid")
.build();
}
}
```
## 使用`AuthMyGitlabRequest`实现Gitlab登录
```java
AuthRequest authRequest = new AuthMyGitlabRequest(AuthConfig.builder()
.clientId("63398e403231d4aa7e856cf5413620d536a876cb94e8d10ced0d3191b5d1d246")
.clientSecret("65b0eba68fff019e682e6755882a24dfdbf0a61be55de119cb8970320186c8eb")
.redirectUri("http://127.0.0.1:8443/oauth/callback/mygitlab")
.build());
```
> 注:完整代码都在[JustAuth-demo](https://github.com/justauth/JustAuth-demo)Demo项目中,本节只讲解关键代码
## 效果
![gitlab私服验证授权](./_media/custom/gitlab3.png)
![gitlab私服登录完成](./_media/custom/gitlab4.png)
# 自定义state缓存
> starter 内置了2种缓存实现,一种是上一节演示的默认实现,另一种是用户自定义的扩展实现。
本节将会使用[JustAuth-demo](https://github.com/justauth/JustAuth-demo)Demo进行演示扩展Redis缓存的方式,当然了,你也可以自定义实现你自己的缓存。
待补充
## 添加 Redis 依赖
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
```
### 添加redis配置
```xml
# 集成redis实现自定义的state缓存
spring.redis.database=0
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=xxxx
```
### 实现state缓存接口
```java
package me.zhyd.justauth;
import me.zhyd.oauth.cache.AuthCacheConfig;
import me.zhyd.oauth.cache.AuthStateCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.concurrent.TimeUnit;
/**
* 扩展Redis版的state缓存
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @date 2019/10/24 13:38
* @since 1.8
*/
@Component
public class AuthStateRedisCache implements AuthStateCache {
@Autowired
private RedisTemplate<String, String> redisTemplate;
private ValueOperations<String, String> valueOperations;
@PostConstruct
public void init() {
valueOperations = redisTemplate.opsForValue();
}
/**
* 存入缓存,默认3分钟
*
* @param key 缓存key
* @param value 缓存内容
*/
@Override
public void cache(String key, String value) {
valueOperations.set(key, value, AuthCacheConfig.timeout, TimeUnit.MILLISECONDS);
}
/**
* 存入缓存
*
* @param key 缓存key
* @param value 缓存内容
* @param timeout 指定缓存过期时间(毫秒)
*/
@Override
public void cache(String key, String value, long timeout) {
valueOperations.set(key, value, timeout, TimeUnit.MILLISECONDS);
}
/**
* 获取缓存内容
*
* @param key 缓存key
* @return 缓存内容
*/
@Override
public String get(String key) {
return valueOperations.get(key);
}
/**
* 是否存在key,如果对应key的value值已过期,也返回false
*
* @param key 缓存key
* @return true:存在key,并且value没过期;false:key不存在或者已过期
*/
@Override
public boolean containsKey(String key) {
return redisTemplate.hasKey(key);
}
}
```
### 获取Request
本节以Gitee为例
```java
// 1. 注入新添加的cache
@Autowired
private AuthStateRedisCache stateRedisCache;
// 2. 创建request时传入stateRedisCache
AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build(), stateRedisCache);// 此处传入自定义实现的类
```
到此已经完成了通过redis**扩展实现state缓存**的功能。当然,只要你愿意,你可以使用**任何一种**缓存技术去实现这个功能,并不局限于redis。
......@@ -153,3 +153,16 @@ public Object revokeAuth(@PathVariable("source") String source, @PathVariable("t
- [实现Github授权登录](http://t.cn/EJ0Fxqo)
- [Spring Boot 快速集成第三方登录功能](http://t.cn/AiWWx5kH) : QQ、Github、微信、谷歌、微软、小米、企业微信
- [集成企业微信](https://mp.weixin.qq.com/s?__biz=MzA3NDk3OTIwMg==&mid=2450633170&idx=2&sn=456b70742a86948a193c691f3e47b72e&chksm=8892933fbfe51a29c1da386a2252d4bf91bfbd14e1ac0b99b783763a0d12e2e4b2d7c4369933&token=482455242&lang=zh_CN#rd)
## 配套项目
**配套Demo**
- [JustAuth-demo](https://github.com/justauth/JustAuth-demo):普通版springboot项目demo
- [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)
- [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
## springboot 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-demo](https://github.com/justauth/justauth-spring-boot-starter-demo): Spring Boot 使用 justauth-spring-boot-starter 快速集成 JustAuth by [xkcoding](https://github.com/xkcoding)
......@@ -74,5 +74,7 @@
}
</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>mermaid.initialize({startOnLoad:true});</script>
</body>
</html>
......@@ -5,7 +5,7 @@
- [The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749)
- [OAuth 2.0](https://oauth.net/2/)
## OAuth 2的授权流程
## OAuth 2 的授权流程
### 参与的角色
......@@ -38,6 +38,8 @@
上面的流程图取自[The OAuth 2.0 Authorization Framework#1.2](https://tools.ietf.org/html/rfc6749#section-1.2)
**流程解析**
- (A) 用户打开**客户端**以后,**客户端**要求**用户**给予授权。
- (B) **用户**同意给予**客户端**授权。
- (C) **客户端**使用上一步获得的授权,向**认证服务器**申请令牌。
......@@ -56,6 +58,25 @@
- Client Credentials
- 适用于客户端调用主服务API型应用(比如百度API Store)
`JustAuth`中是使用的`Authorization Code`授权方式,下面将主要讲解`Authorization Code`的授权流程
## 直白话 OAuth 2 流程
以上流程理解起来可能有些难度,这儿我们给出一个白话版的流程图
这儿引入三个角色:
- 用户A:可以理解成你自己
- 网站B:可以理解成 Oschina
- 第三方C:可以理解成 Github
需求:你想通过Github第三方登录Oschina
(未完待续)
\ No newline at end of file
<div class="mermaid">
sequenceDiagram
用户A->>网站B: 1.我想登录你
网站B->>用户A: 2.我不认识你
用户A->>第三方C: 3.老铁我去过你那儿,咱俩认识,你帮我授权给网站B
第三方C->>网站B: 4.用户A是我老铁,给你他的授权码
网站B->>第三方C: 5.这个授权码是你那儿的人吗?是的话给我他的令牌
第三方C->>网站B: 6.是我这儿的人,让他登录吧
网站B->>用户A: 7.得嘞,您走着
用户A->>网站B: 8.登录成功
</div>
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
## 1. 申请应用
### 1.1 注册账号
注册Gitee账号:[https://gitee.com](https://gitee.com)。如果已有则忽略该步骤,直接进入第二步。
### 1.2 创建第三方授权应用
进入第三方应用页面([https://gitee.com/oauth/applications](https://gitee.com/oauth/applications)
![Gitee第三方应用管理页面](../_media/oauth/gitee_02.png)
创建应用
![创建OAuth应用](../_media/oauth/gitee_03.png)
- **应用名称** 一般填写自己的网站名称即可
- **应用描述** 一般填写自己的应用描述即可
- **应用主页** 填写自己的网站首页地址
- **应用回调地址** 重点,该地址为用户授权后需要跳转到的自己网站的地址,默认携带一个code参数
- **权限** 根据页面提示操作,默认勾选第一个就行。
以上信息输入完成后,点击确定按钮创建应用。创建完成后,点击进入应用详情页,可以看到应用的密钥等信息
![应用详情](../_media/oauth/gitee_04.png)
记录以下三个信息:`Client ID``Client Secret``应用回调地址`,后面我们会用到
## 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 AuthGiteeRequest(AuthConfig.builder()
.clientId("Client ID")
.clientSecret("Client Secret")
.redirectUri("应用回调地址")
.build());
```
### 2.3 生成授权地址
我们可以直接使用以下方式生成第三方平台的授权链接:
```java
String authorizeUrl = authRequest.authorize();
```
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
### 2.4 以上完整代码如下
```java
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthRequest;
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());
}
@RequestMapping("/callback")
public Object login(String code) {
AuthRequest authRequest = getAuthRequest();
return authRequest.login(code);
}
private AuthRequest getAuthRequest() {
return new AuthGiteeRequest(AuthConfig.builder()
.clientId("Client ID")
.clientSecret("Client Secret")
.redirectUri("应用回调地址")
.build());
}
}
```
授权链接访问成功后会看到以下页面内容:
![授权登录](../_media/oauth/gitee_01.png)
点击同意授权即可完成gitee的oauth登录。
## 3. 授权结果
注:数据以脱敏
```json
{
"code": 2000,
"msg": null,
"data": {
"uuid": "xxx",
"username": "yadong.zhang",
"nickname": "yadong.zhang",
"avatar": "https://avatar.gitee.com/uploads/99/784199_yadong.zhang.png?1462325358",
"blog": "https://www.zhyd.me",
"company": null,
"location": null,
"email": null,
"remark": "程序员",
"gender": "UNKNOWN",
"source": "GITEE",
"token": {
"accessToken": "630740bxxxxxxxx4",
"expireIn": 86400,
"refreshToken": "1f2e0faedxxxxx537ec8",
"uid": null,
"openId": null,
"accessCode": null,
"unionId": null,
"scope": "user_info",
"tokenType": "bearer",
"idToken": null,
"macAlgorithm": null,
"macKey": null,
"code": null
}
}
}
```
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
## 1. 申请应用
企业可通过两种途径申请应用,一、直接通过线下商务合作,由商务人员线下提供开通的对应应用的秘钥信息。二、线上自助申请(此步骤申请的应用可以在应用审核上线后出现在商家后台的应用市场内)。此步骤主要介绍线上自助申请的流程,若以获取到对应的秘钥信息,则直接进入步骤2.
注意:目前酷家乐的开放平台只针对合作企业开放,暂时不对个人开发者开放。商务合作或酷家乐应用市场相关信息可访问[https://www.kujiale.com/](酷家乐首页)通过首页上的在线客服咨询。
### 1.1 注册账号
注册酷家乐账号:[https://www.kujiale.com/](https://www.kujiale.com/)。如果已有则忽略该步骤,直接进入第二步。(一般建议直接使用企业账号)
### 1.2 认证开发者
进入酷家乐开放平台([https://open.kujiale.com/](https://open.kujiale.com/))点击右上角的管理中心进入第三方应用管理页面。
![酷家乐第三方应用管理中心](../_media/oauth/kujiale_1.png)
首次进入左侧菜单栏的-服务入驻申请模块,系统会要求进行开发者实名认证。
![实名认证](../_media/oauth/kujiale_2.png)
根据实名认证的流程,开发者需要依次提供:1.开发者信息,2.开发者企业信息,3.开发者企业人员构成信息,4.开发者企业经验背景信息
![实名认证流程](../_media/oauth/kujiale_3.png)
在2-3个工作日内,酷家乐运营同学会对提交信息进行审核,审核通过后可进入应用申请。
ps:如果有商务同学跟进的话可以联系商务同学提速,基本在1小时内能得到响应。
### 1.2 创建第三方授权应用
进入服务入驻申请模块([https://open.kujiale.com/open/management/service-application](服务入驻申请)),申请应用服务。
![创建应用信息](../_media/oauth/kujiale_4.png)
选择服务类型以后提供相应的应用信息申请应用。
![创建应用信息](../_media/oauth/kujiale_5.png)
oauth2.0基础信息
- **应用名称** 一般填写自己的网站名称即可
- **应用简介** 填写应用描述,预期实现的功能场景。
- **应用回调地址** 重点,该地址为用户授权后需要跳转到的自己网站的地址,默认携带一个code参数
- **OAuth申请** 根据申请应用的具体业务场景而定,获取账号基本信息为其他权限(可申请用户授权资源项)申请的基础,即获取账号基本信息必选。若只是依托于酷家乐账号登录则只选择获取账号基本信息即可。
应用市场基础信息(当前只提供应用市场申请能力;应用市场的具体的营销规则,合作模式以及营销分成规则可通过在线客服与我们的商务同学取得联系。)
- **应用图标** 应用图标是应用展示在酷家乐应用市场内的图片表示,一般可以提供商家的品牌logo
- **购买通知地址** 当应用在应用市场内由其他商家付钱触发购买行为,酷家乐会通过此接口向第三方推送购买通知。
联系信息
- **咨询电话** 第三方需要为自己在酷家乐应用市场内的应用提供客户咨询能力。
- **客服链接** 第三方需要为自己在酷家乐应用市场内的应用提供客服支持。
- **开发者邮箱** 应用负责人联系邮箱,用于推送相关应用信息,例如:应用状态,应用服务情况,应用数据统计情况,以及相关的酷家乐接口迭代推送。
- **开发者电话** 应用负责人联系人电话,帮助在系统层面出现问题时候可以快速联系到负责人。
协议信息
- **应用协议名称** 应用的使用者需要知晓并且同意的协议名称。
- **应用协议内容** 应用的使用者需要知晓并且同意才可以使用购买该应用的协议内容。
保存并提交审核后,由运营在管理后台审核应用的相关信息以及应用申请相关权限的合理性。在审核通过后,可以在应用服务模块中查看到该应用,同时访问应用详情可以获取到此应用的秘钥信息(client_id:应用的唯一标识。client_secret:client_id对应的密钥,访问用户资源时用来验证应用的合法性。)
## 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 AuthKujialeRequest(AuthConfig.builder()
.clientId("Client ID")
.clientSecret("Client Secret")
.redirectUri("应用回调地址")
.build());
```
### 2.3 生成授权地址
我们可以直接使用以下方式生成第三方平台的授权链接:
```java
String authorizeUrl = authRequest.authorize(String state);
```
这个授权链接,默认的是`get_user_info`scope,即只想用户申请用户基本信息的授权,如果想自定义`scope`可以使用如下方式,单独传入对应的`scope`即可
```java
String authorizeUrl = authRequest.authorize(String state, String scopeStr);
```
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
参数说明:
- state:用于防范CSRF攻击,各第三方可以视自己网站的安全性而定(建议预先了解一下oauth2.0的技术以及state参数的意义)
- scopeStr:酷家乐授权选项scope,以逗号隔开,具体资源可以参考每个[https://open.kujiale.com/open/apps?app_id=2](酷家乐开放接口文档)内的授权scope内容。
### 2.4 以上完整代码如下
```java
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthKujialeRequest;
import me.zhyd.oauth.request.AuthRequest;
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("state"));
}
@RequestMapping("/callback")
public Object login(String code, String state) {
AuthRequest authRequest = getAuthRequest();
//此处如果对安全性有要求,请校验state参数
return authRequest.login(code);
}
private AuthRequest getAuthRequest() {
return new AuthKujialeRequest(AuthConfig.builder()
.clientId("Client ID")
.clientSecret("Client Secret")
.redirectUri("应用回调地址")
.build());
}
}
```
授权链接访问成功后会看到以下页面内容:
![授权登录](../_media/oauth/kujiale_6.png)
点击同意授权即可完成酷家乐的oauth登录。
## 3. 授权结果
注:数据已脱敏
```json
{
"code": 2000,
"msg": null,
"data": {
"uuid": "xxx",
"username": "yadong.zhang",
"nickname": "yadong.zhang",
"avatar": "https://qhyxpicoss.kujiale.com/avatars/2017/03/03/origin8762512743744383438.jpg",
"blog": null,
"company": null,
"location": null,
"email": null,
"remark": null,
"gender": null,
"source": "KUJIALE",
"token": {
"accessToken": "630740bxxxxxxxx4",
"expireIn": 86400,
"refreshToken": "1f2e0faedxxxxx537ec8",
"uid": null,
"openId": null,
"accessCode": null,
"unionId": null,
"scope": null,
"tokenType": null,
"idToken": null,
"macAlgorithm": null,
"macKey": null,
"code": null
}
}
}
```
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
(敬请期待...)
## 1. 申请应用
## 2. 集成JustAuth
## 3. 授权结果
\ No newline at end of file
**配套Demo**
- [Springboot](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)
- [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)
......
......@@ -5,12 +5,12 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
/**
* OAuth平台的API管理类的统一接口,提供以下接口
* 1) {@link AuthSource#authorize()}: 获取授权api. 必须实现
* 2) {@link AuthSource#accessToken()}: 获取授权api. 必须实现
* 3) {@link AuthSource#userInfo()}: 获取授权api. 必须实现
* 4) {@link AuthSource#revoke()}: 获取授权api. 非必须实现接口(部分平台不支持)
* 5) {@link AuthSource#refresh()} ()}: 获取授权api. 非必须实现接口(部分平台不支持)
* OAuth平台的API地址的统一接口,提供以下方法
* 1) {@link AuthSource#authorize()}: 获取授权url. 必须实现
* 2) {@link AuthSource#accessToken()}: 获取accessToken的url. 必须实现
* 3) {@link AuthSource#userInfo()}: 获取用户信息的url. 必须实现
* 4) {@link AuthSource#revoke()}: 获取取消授权的url. 非必须实现接口(部分平台不支持)
* 5) {@link AuthSource#refresh()}: 获取刷新授权的url. 非必须实现接口(部分平台不支持)
* <p>
* 注:
* ①、如需通过JustAuth扩展实现第三方授权,请参考{@link AuthDefaultSource}自行创建对应的枚举类并实现{@link AuthSource}接口
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册