diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
index 55b740b56ad88c291c99e42ad4bc4f028b34638c..9077e2240c40d4445b07132e5c255e0ca4aa1076 100644
--- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
+++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
@@ -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)
+
diff --git a/README.en-US.md b/README.en-US.md
index 6905b90850cfa332daf101e0a627b56fbd9db3c1..b0ca4c3c917b645bfc992ced734976a15332f560 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -68,6 +68,7 @@
|
|
|
+ |
@@ -100,7 +101,7 @@ These artifacts are available from Maven Central:
me.zhyd.oauth
JustAuth
- ${latest.version}
+ 1.13.0
```
- Using JustAuth
@@ -162,7 +163,7 @@ authRequest.login(callback);
| | [AuthGitlabRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java) | 参考文档 |
| | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | 参考文档 |
| | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | 参考文档 |
-| | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | 参考文档 |
+| | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
diff --git a/README.md b/README.md
index 655500a98337997e3a1c14284cd24975e7f35066..3c4bd06e277e3f92e1d244fb48e7e2b837c33782 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -68,6 +68,7 @@
|
|
|
+ |
@@ -100,7 +101,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
me.zhyd.oauth
JustAuth
- 1.12.0
+ 1.13.0
```
- 调用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);
| | [AuthGitlabRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java) | 参考文档 |
| | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | 参考文档 |
| | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | 参考文档 |
-| | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | 参考文档 |
+| | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
_请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_
diff --git a/docs/Q&A.md b/docs/Q&A.md
index 49303ddd1642e67b9f4132fe70ff839075efcc23..4affc30c56ce9eb13dadc6651eea766184714541 100644
--- a/docs/Q&A.md
+++ b/docs/Q&A.md
@@ -1,4 +1,25 @@
-## ~~升级到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
3.7.4.ALL
```
+
+## 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
diff --git a/docs/README.md b/docs/README.md
index 017fab189b789911543a7bab4c801486418015ff..6b8f3b50ee479ac64995dbfc75b3395b0464710f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -9,7 +9,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
@@ -91,6 +91,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
| | [AuthGitlabRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java) | 参考文档 |
| | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | 参考文档 |
| | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | 参考文档 |
+| | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
diff --git a/docs/_coverpage.md b/docs/_coverpage.md
index d3f43875d4f056650f2fa2502d9c46b2d3e469b6..372bb568acc0c4dd0285de3e854cd80464bdb2f2 100644
--- a/docs/_coverpage.md
+++ b/docs/_coverpage.md
@@ -1,6 +1,6 @@
![](_media/logo.png)
-# JustAuth 1.12.0
+# JustAuth 1.13.0
史上最全的整合第三方登录的开源库
diff --git a/docs/_media/custom/gitlab.png b/docs/_media/custom/gitlab.png
new file mode 100644
index 0000000000000000000000000000000000000000..567f6fcd0850cf2ca54bc127b050d410b2699b25
Binary files /dev/null and b/docs/_media/custom/gitlab.png differ
diff --git a/docs/_media/custom/gitlab2.png b/docs/_media/custom/gitlab2.png
new file mode 100644
index 0000000000000000000000000000000000000000..26b904d13493196a9f345487339989f56b20e823
Binary files /dev/null and b/docs/_media/custom/gitlab2.png differ
diff --git a/docs/_media/custom/gitlab3.png b/docs/_media/custom/gitlab3.png
new file mode 100644
index 0000000000000000000000000000000000000000..679930a2a1394ba5e40830bc1cc064794699dfe0
Binary files /dev/null and b/docs/_media/custom/gitlab3.png differ
diff --git a/docs/_media/custom/gitlab4.png b/docs/_media/custom/gitlab4.png
new file mode 100644
index 0000000000000000000000000000000000000000..4049d38efe3829f820e9b7f189edc3a5e452c2c0
Binary files /dev/null and b/docs/_media/custom/gitlab4.png differ
diff --git a/docs/_media/oauth/gitee_01.png b/docs/_media/oauth/gitee_01.png
new file mode 100644
index 0000000000000000000000000000000000000000..3c8d6edd6b6fec39a2b4fa684d355ac961dcf05e
Binary files /dev/null and b/docs/_media/oauth/gitee_01.png differ
diff --git a/docs/_media/oauth/gitee_02.png b/docs/_media/oauth/gitee_02.png
new file mode 100644
index 0000000000000000000000000000000000000000..03e6778adc4075aa37988a85c668c9f68d072f0b
Binary files /dev/null and b/docs/_media/oauth/gitee_02.png differ
diff --git a/docs/_media/oauth/gitee_03.png b/docs/_media/oauth/gitee_03.png
new file mode 100644
index 0000000000000000000000000000000000000000..6987ab9a22c394a19bdaaf900c409e37fcd6844c
Binary files /dev/null and b/docs/_media/oauth/gitee_03.png differ
diff --git a/docs/_media/oauth/gitee_04.png b/docs/_media/oauth/gitee_04.png
new file mode 100644
index 0000000000000000000000000000000000000000..4d1e91eaecb1b46ae816db5a83b6e87eee816025
Binary files /dev/null and b/docs/_media/oauth/gitee_04.png differ
diff --git a/docs/_media/oauth/kujiale_1.png b/docs/_media/oauth/kujiale_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..02eb4626367e0919baa6455465919212c120dce4
Binary files /dev/null and b/docs/_media/oauth/kujiale_1.png differ
diff --git a/docs/_media/oauth/kujiale_2.png b/docs/_media/oauth/kujiale_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..dac82e0be86417772c41f31cc47f2d4ce8d56847
Binary files /dev/null and b/docs/_media/oauth/kujiale_2.png differ
diff --git a/docs/_media/oauth/kujiale_3.png b/docs/_media/oauth/kujiale_3.png
new file mode 100644
index 0000000000000000000000000000000000000000..71552ff005f90a025a4e652715a97e7e32dec024
Binary files /dev/null and b/docs/_media/oauth/kujiale_3.png differ
diff --git a/docs/_media/oauth/kujiale_4.png b/docs/_media/oauth/kujiale_4.png
new file mode 100644
index 0000000000000000000000000000000000000000..5dc48a1fdf88af297bb8305a90294b2509d95967
Binary files /dev/null and b/docs/_media/oauth/kujiale_4.png differ
diff --git a/docs/_media/oauth/kujiale_5.png b/docs/_media/oauth/kujiale_5.png
new file mode 100644
index 0000000000000000000000000000000000000000..1dd25bfe743adb4a88fa285d89cf9c619ad313e1
Binary files /dev/null and b/docs/_media/oauth/kujiale_5.png differ
diff --git a/docs/_media/oauth/kujiale_6.png b/docs/_media/oauth/kujiale_6.png
new file mode 100644
index 0000000000000000000000000000000000000000..5af409b772882ee2042d65edb65bf02c6498087d
Binary files /dev/null and b/docs/_media/oauth/kujiale_6.png differ
diff --git a/docs/_media/scope_error.png b/docs/_media/scope_error.png
new file mode 100644
index 0000000000000000000000000000000000000000..33f4b8717df38bf8cd49744fdc1dd5c1609e0b96
Binary files /dev/null and b/docs/_media/scope_error.png differ
diff --git a/docs/_media/scope_error2.png b/docs/_media/scope_error2.png
new file mode 100644
index 0000000000000000000000000000000000000000..db50aae6b1027ea44bc5152f1da42885e2c9059c
Binary files /dev/null and b/docs/_media/scope_error2.png differ
diff --git a/docs/_sidebar.md b/docs/_sidebar.md
index deb1e5c112203556770b0592a51dda1308f47722..0e16a670914eefd95e2045ec13edc45ce01f7884 100644
--- a/docs/_sidebar.md
+++ b/docs/_sidebar.md
@@ -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)
diff --git a/docs/contributors.md b/docs/contributors.md
index 8393a50b766109be8e5c6f21fe3d31755b24ac99..ad11a9e87e9b8bfe35de90e82d8539738c4ce960 100644
--- a/docs/contributors.md
+++ b/docs/contributors.md
@@ -10,7 +10,7 @@
- 提供ActFramework版demo
- 提供SpringBoot快速集成的justauth-spring-boot-starter
- · pengisgood : [Github] | [个人网站]
- - 集成人人登录、Pinterest登录、StackOverflow登录
+ - 集成人人登录、Pinterest登录、StackOverflow登录、Twitter登录
- · skqing : [Gitee] | [个人网站]
- 修复钉钉登录的部分问题
- 优化微博登录
diff --git a/docs/customize-the-oauth.md b/docs/customize-the-oauth.md
new file mode 100644
index 0000000000000000000000000000000000000000..efe69e0c53cf5073a42590e38c8482943ef5ed2a
--- /dev/null
+++ b/docs/customize-the-oauth.md
@@ -0,0 +1,208 @@
+# 自定义第三方平台的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)
+
+
+
diff --git a/docs/customize-the-state-cache.md b/docs/customize-the-state-cache.md
index 4f1fc91b18f280e4d377f6eb5f1ec1d2aa7e3773..af8e532ef0f76e4212b52d4030052e46f2c5028e 100644
--- a/docs/customize-the-state-cache.md
+++ b/docs/customize-the-state-cache.md
@@ -1,3 +1,123 @@
# 自定义state缓存
+> starter 内置了2种缓存实现,一种是上一节演示的默认实现,另一种是用户自定义的扩展实现。
+本节将会使用[JustAuth-demo](https://github.com/justauth/JustAuth-demo)Demo进行演示扩展Redis缓存的方式,当然了,你也可以自定义实现你自己的缓存。
-待补充
+## 添加 Redis 依赖
+```xml
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+```
+
+### 添加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 redisTemplate;
+
+ private ValueOperations 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。
diff --git a/docs/how-to-use.md b/docs/how-to-use.md
index 23f4ab2af4483d08c5dc6d43479d164981603a69..519bc5efa0d231293b3805b79fc12805dd10175e 100644
--- a/docs/how-to-use.md
+++ b/docs/how-to-use.md
@@ -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)
diff --git a/docs/index.html b/docs/index.html
index 615050559ba810908825327249f7ea5ec8222c2e..35f09f51606a57344bf2465518d47585bd97f54c 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -74,5 +74,7 @@
}
+
+