Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94f6540338 | |||
| 7bc7a92efb | |||
| b5920872d5 | |||
| 0bdf881849 | |||
| 46f7c72744 | |||
| 4a662ba5cd | |||
| 040587d5b2 | |||
| c81411fd39 | |||
| 0e1b000bd8 | |||
| f9b30c735b | |||
| 0f42457d91 | |||
| fa75568996 | |||
| f44ceeeeeb | |||
| ec4c009ed8 | |||
| 03fbbe0d3a | |||
| e64e9def63 | |||
| 25f99f7560 | |||
| 0433f54564 | |||
| 423d9f45b6 | |||
| 7a9e6214de | |||
| 3753e3b9bc | |||
| bc3af96328 | |||
| b700902c04 | |||
| 2d0ae7cc27 | |||
| 3e4faa75fe | |||
| 6a36ad6af2 | |||
| 13514d6a92 | |||
| 6a479d9c1d | |||
| 2e64fb9693 | |||
| 0e8308e6c9 | |||
| 3933b3b7ee | |||
| a99b818810 | |||
| cd324cc7c1 | |||
| 3e890f2c2a | |||
| ba56f5ab5a | |||
| 132a7f4338 | |||
| c79b97a0d0 | |||
| 66df3ac027 | |||
| 11df93ad44 | |||
| e3f5f49ec8 | |||
| 23eb2cfcc8 | |||
| 30461e62f9 | |||
| dfbbd9ae0d | |||
| 05b7746f26 | |||
| 21422b02aa | |||
| 10e445e87c | |||
| d6cbcecaab | |||
| 050459e616 | |||
| 9fd2b9b919 | |||
| 2ff5570399 | |||
| 1bec384525 | |||
| 824c68356d | |||
| f5e3c225f6 | |||
| 0259669288 | |||
| edc9d1a3c3 | |||
| d886bc95a2 | |||
| 7aaf52e953 | |||
| e84bd7cdb5 | |||
| 28e19960f2 | |||
| dce2bd1e1e | |||
| bc30971482 | |||
| 9bd6d88049 | |||
| 442332be57 | |||
| d4bfa8e75f | |||
| fb90fbdcb8 | |||
| 5f6cb2954f | |||
| 906ae659a2 | |||
| cebfd99703 | |||
| 71b6080156 | |||
| 492ffdbbf8 | |||
| dc4093bdf3 | |||
| b71b081c96 | |||
| 6b00783cd9 | |||
| 2723f0dc3d |
@@ -10,7 +10,7 @@ assignees: ''
|
||||
|
||||
- [ ] I have searched the relevant information in the existing list of Issues.
|
||||
- [ ] I have searched the developer documentation for that information: https://justauth.wiki
|
||||
- [ ] I have read the relevant Q&A: https://justauth.wiki/#/Q&A
|
||||
- [ ] I have read the relevant Q&A: https://justauth.wiki
|
||||
|
||||
## Issue description
|
||||
|
||||
|
||||
@@ -34,3 +34,4 @@ bin/push-dev.sh
|
||||
target
|
||||
/pom.xml.versionsBackup
|
||||
/gpg
|
||||
/PLAN.md
|
||||
|
||||
+485
@@ -0,0 +1,485 @@
|
||||
## 1.16.1
|
||||
|
||||
### 2021/4/19
|
||||
|
||||
- 发布 v1.16.1
|
||||
- Fix Github issue [#114](https://github.com/justauth/JustAuth/issues/114): 解决企业微信授权后,回调地址中原有的参数丢失的问题
|
||||
- Fix Github issue [#82](https://github.com/justauth/JustAuth/issues/82): 抖音平台支持自定义 scope
|
||||
- Fix Github issue [#92](https://github.com/justauth/JustAuth/issues/92): 增加忽略校验 redirectUri 的配置
|
||||
- Merge Github PR [#115](https://github.com/justauth/JustAuth/pull/115)
|
||||
- 升级 `fastjson` 到 `v1.2.76`
|
||||
|
||||
## 1.16.0
|
||||
|
||||
### 2021/4/7
|
||||
|
||||
- 发布 v1.16.0
|
||||
- 新增
|
||||
- 集成 Amazon 平台登录
|
||||
- 集成 Slack 平台登录
|
||||
- 集成 LINE 平台登录
|
||||
- 集成 Okta 平台登录
|
||||
- 集成钉钉账号登录
|
||||
- 修改
|
||||
- 【**重要**】 `AuthConfig`中的`codingGroupName`参数更名为`domainPrefix`,针对此类平台提供通用的配置。
|
||||
- 修改 `AuthFacebookScope` 中的默认 scope,解决 justauth-demo 项目中使用 facebook 报错的问题
|
||||
- 升级 facebook 的 api 到 v10.0 版本
|
||||
- 优化部分代码
|
||||
- 优化 Map 声明时的初始容量,避免频繁扩容
|
||||
- 更新 README 文档
|
||||
- PR
|
||||
- 合并 [Github #110](https://github.com/justauth/JustAuth/pull/110)
|
||||
- 合并 [Gitee #22](https://gitee.com/yadong.zhang/JustAuth/pulls/22)
|
||||
|
||||
## 1.15.9
|
||||
|
||||
### 2021/1/1
|
||||
|
||||
- 发布 v1.15.9
|
||||
- 新增
|
||||
- 修复并正式启用 飞书 平台的第三方登录
|
||||
- AuthToken 类中新增 `refreshTokenExpireIn` 记录 refresh token 的有效期
|
||||
- PR
|
||||
- 合并 [Github #101](https://github.com/justauth/JustAuth/pull/101) :支持喜马拉雅登录
|
||||
- 合并 [Github #105](https://github.com/justauth/JustAuth/pull/105) :支持企业微信网页授权登录
|
||||
- 合并 [Github #107](https://github.com/justauth/JustAuth/pull/107) :添加AuthAlipayRequest网络代理构造器,解决 Github Issue [#102](https://github.com/justauth/JustAuth/issues/102)
|
||||
- 修改
|
||||
- 修改喜马拉雅配置参数,将`ClientOsType`参数提到 AuthConfig 中
|
||||
- AuthChecker 中增加对喜马拉雅平台的校验
|
||||
- 升级 facebook api 版本到 v9.0,解决 Gitee Issue [#I2AR5S](https://gitee.com/yadong.zhang/JustAuth/issues/I2AR5S)
|
||||
- !!!**注意**!!!修改原来的企业微信 Request 类名为 `AuthWeChatEnterpriseQrcodeRequest`,升级后注意该点
|
||||
|
||||
注意:可能有些开发者对于 JA 集成的四个微信平台不太理解,这儿统一说明:
|
||||
- 按照类名
|
||||
- AuthWeChatEnterpriseQrcodeRequest:企业微信二维码登录
|
||||
- AuthWeChatEnterpriseWebRequest:企业微信网页登录
|
||||
- AuthWeChatOpenRequest:微信开放平台
|
||||
- AuthWeChatMpRequest:微信公众平台
|
||||
- 按照枚举
|
||||
- WECHAT_ENTERPRISE:企业微信二维码登录
|
||||
- WECHAT_ENTERPRISE_WEB:企业微信网页登录
|
||||
- WECHAT_OPEN:微信开放平台
|
||||
- WECHAT_MP:微信公众平台
|
||||
|
||||
## 1.15.8
|
||||
|
||||
### 2020/10/25
|
||||
|
||||
- Release version 1.15.8
|
||||
- Merge the pr. [#95](https://github.com/justauth/JustAuth/pull/95) [#96](https://github.com/justauth/JustAuth/pull/96)
|
||||
|
||||
## 1.15.7
|
||||
|
||||
### 2020/09/11
|
||||
|
||||
- Release version 1.15.7
|
||||
- Upgrade the use of access token when obtaining resources on the github platform.Reference from [Deprecating API authentication through query parameters](https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/)
|
||||
- Fixed issue. [#89](https://github.com/justauth/JustAuth/issues/89)
|
||||
|
||||
## 1.15.7-beta.3
|
||||
|
||||
### 2020/08/24
|
||||
|
||||
- Fixing a bug for wechat.
|
||||
- Improve the Microsoft platform's questions about scope.
|
||||
|
||||
## 1.15.7-beta.1
|
||||
|
||||
### 2020/08/05
|
||||
|
||||
- 新增
|
||||
- 以下平台支持自定义 Scope 参数:百度、coding、Facebook、gitee、github、gitlab、google、华为、京东·宙斯、酷家乐、领英、微软、小米、Pinterest、QQ、人人网、StackOverflow、微博、微信公众平台
|
||||
- 添加 PR 和 ISSUE 规范和 CODE_OF_CONDUCT 文档
|
||||
- 合并
|
||||
- 合并 Gitee [PR#19](https://gitee.com/yadong.zhang/JustAuth/pulls/19),修复通过google登录一次后,重新用google登录无法切换谷歌账户的问题。
|
||||
|
||||
## 1.15.6
|
||||
|
||||
### 2020/06/30
|
||||
- 文档
|
||||
- 新增 [百度登录](oauth/baidu.md)文档
|
||||
- 新增 [钉钉登录](oauth/alipay.md)文档
|
||||
- 新增 [开源中国登录](contributors.md)文档
|
||||
- 新增 [领英登录](references.md)文档
|
||||
- 新增 [Google 登录](references.md)文档
|
||||
- 新增 [微信企业版登录](oauth/wechatEnterprise.md)文档
|
||||
- 新增 [Facebook 登录](oauth/facebook.md)文档
|
||||
- 完善 [JustAuth 使用者](users.md)文档
|
||||
- 替换“帮助文档”域名,由[https://docs.justauth.whnb.wang](https://docs.justauth.whnb.wang)迁移到[https://justauth.wiki](https://justauth.wiki)
|
||||
- 新增
|
||||
- 增加阿里云授权登录中刷新授权token的接口,by “QQ群用户需求”
|
||||
- AuthConfig 增加忽略校验 state 的参数,详情参考:[Github#Issue#83](https://github.com/justauth/JustAuth/issues/83)
|
||||
- 移除领英刷新token的接口。参考官网:`To refresh an access token, go through the authorization process again to fetch a new token.`
|
||||
|
||||
## 1.15.5
|
||||
### 2020/06/24
|
||||
- BUG
|
||||
- 解决 `Microsoft` 授权失败的 BUG
|
||||
- 解决 `Coding` 个人账号授权失败的 BUG(目前只能使用团队模式进行授权,需要传入团队名,参考`AuthConfig#codingGroupName`)
|
||||
- 解决 `AuthLinkedinRequest#getAvatar` NPE 的问题。(领英用户没有头像时,原代码会报 NPE)
|
||||
- 解决抖音登录获取用户地址异常的问题。
|
||||
- 解决人人网登录时 token 中带有 `|` 引起的异常,[Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)
|
||||
- 新增
|
||||
- 支持阿里云授权登录,[Github#81](https://github.com/justauth/JustAuth/pull/81)
|
||||
- AuthUser 中新增 `rawUserInfo`,用来存放第三方平台返回的原始用户数据。注:淘宝平台的`rawUserInfo`为一个空 JSON
|
||||
- 支持 Http 级的代理配置,使用方式:
|
||||
```java
|
||||
new AuthGoogleRequest(AuthConfig.builder()
|
||||
.clientId("")
|
||||
.clientSecret("")
|
||||
.redirectUri("http://127.0.0.1:8443/oauth/callback/google")
|
||||
// 针对国外平台配置代理
|
||||
.httpConfig(HttpConfig.builder()
|
||||
.timeout(15000)
|
||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
.build())
|
||||
.build());
|
||||
```
|
||||
- 修改
|
||||
- 升级 [simple-http](https://github.com/xkcoding/simple-http) 到 `v1.0.2`
|
||||
- 升级 `fastjson` 到 `v1.2.71`
|
||||
- 删除
|
||||
- :boom: 删除**腾讯云登录**。coding 已并入 腾讯云,因此只保留 coding 登录 :boom:
|
||||
- 文档
|
||||
- 新增 [Coding登录](oauth/coding.md)文档
|
||||
- 完善 [支付宝登录](oauth/alipay.md)文档
|
||||
- 完善 [贡献者名单](contributors.md)文档
|
||||
- 完善 [参考文档](references.md)文档
|
||||
- PR
|
||||
- 合并 [Gitee!17](https://gitee.com/yadong.zhang/JustAuth/pulls/17)
|
||||
- 合并 [Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)
|
||||
- 合并 [Github#81](https://github.com/justauth/JustAuth/pull/81)
|
||||
- Issues
|
||||
- 解决 [Github#80](https://github.com/justauth/JustAuth/issues/80)
|
||||
- 解决 [Github#75](https://github.com/justauth/JustAuth/issues/75)
|
||||
|
||||
## 1.15.4-alpha
|
||||
### 2020/05/13
|
||||
- 修复
|
||||
- 解决 Twitter 授权失败的BUG
|
||||
- 文档
|
||||
- 完善 [https://justauth.wiki](https://justauth.wiki/) 的404引导页内容
|
||||
- 增加名词解释: `uuid`
|
||||
- 补充 [Q&A](Q&A.md)
|
||||
- 新增 [参考文档](references.md),包含 OAuth 授权和第三方平台的API文档等内容
|
||||
- 新增 [推特登录](oauth/twitter.md) 的说明文档
|
||||
|
||||
> 特别注意:所有国外平台都无法直接通过java进行访问API,目前[simple-http](https://github.com/xkcoding/simple-http) Release版本,暂不支持添加代理,所以目前需要手动开启代理。
|
||||
|
||||
代理开启的方式:
|
||||
```java
|
||||
System.setProperty("proxyPort", "10080");
|
||||
System.setProperty("proxyHost", "127.0.0.1");
|
||||
```
|
||||
以上代码可以在声明 `AuthRequest` 时创建,也可以全局执行。
|
||||
|
||||
本地如果支持科学上网,就用自己本地的代理端口即可,如果不支持科学上网,可以去网上找一些免费的代理IP进行测试(请自行操作)。
|
||||
|
||||
|
||||
## 1.15.2-alpha
|
||||
### 2020/05/10
|
||||
- 修改
|
||||
- 修复使用领英登录时无法获取token的问题
|
||||
- 解决Gitee [Issue-I1GPIB](https://gitee.com/yadong.zhang/JustAuth/issues/I1GPIB)
|
||||
|
||||
【声明】:当引用 OkHttp 时,无法调用领英的授权登录,可能会抛出 400 异常。如遇此问题,请先切换到 hutool 或者 httpclient 依赖。
|
||||
该问题尚在修复中,给各位带来的不便,深表歉意。
|
||||
|
||||
- hutool-http
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
<version>5.2.5</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- httpclient
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.12</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## v1.15.1(~~v1.15.0~~)
|
||||
### 2020/04/10
|
||||
- 修改
|
||||
- 更新开发文档
|
||||
- 合并Gitee [PR-10](https://gitee.com/yadong.zhang/JustAuth/pulls/10),集成京东登录
|
||||
- 合并Gitee [PR-14](https://gitee.com/yadong.zhang/JustAuth/pulls/14),修改帮助文档,加入JA的使用者信息
|
||||
- 合并Github [PR-69](https://github.com/justauth/JustAuth/pull/69),升级fastjson的最新版本
|
||||
- 解决使用apache-httpclient时的403bug,升级simple-http,感谢QQ群的`不瘦十斤不改名字`反馈该问题
|
||||
- 修复其他一些问题
|
||||
|
||||
【声明】:由于本人的失误,发布了一个错误的版本(1.15.0),目前1.15.0已发布,但是请不要使用,请直接升级到`1.15.1`。
|
||||
|
||||
给各位造成的不便,深表歉意。
|
||||
|
||||
## v1.14.0
|
||||
### 2020/03/17
|
||||
- 修改
|
||||
- 合并[PR-59](https://github.com/justauth/JustAuth/pull/59),抽取HTTP,具体实现交给开发者,解耦 hutool-http,开发者可以视自己项目的依赖决定使用何种HTTP方式。详情请参考:https://github.com/xkcoding/simple-http
|
||||
- 合并[PR-65](https://github.com/justauth/JustAuth/pull/65),修改错误文案
|
||||
- 修复其他一些问题
|
||||
|
||||
## v1.14.0
|
||||
### 2020/03/17
|
||||
- 修改
|
||||
- 合并[PR-59](https://github.com/justauth/JustAuth/pull/59),抽取HTTP,具体实现交给开发者,解耦 hutool-http,开发者可以视自己项目的依赖决定使用何种HTTP方式。详情请参考:https://github.com/xkcoding/simple-http
|
||||
- 合并[PR-65](https://github.com/justauth/JustAuth/pull/65),修改错误文案
|
||||
- 修复其他一些问题
|
||||
|
||||
## v1.13.2
|
||||
### 2019/12/24
|
||||
- 新增
|
||||
- 增加微信、QQ、支付宝、微博授权登录的帮助文档
|
||||
- 合并[PR#57](https://github.com/justauth/JustAuth/pull/57),增加微信公众号登录 by [@xkcoding](https://github.com/xkcoding)
|
||||
- [帮助文档](https://justauth.wiki)中增加自定义的404页面
|
||||
- [帮助文档](https://justauth.wiki)中增加Gittalk插件
|
||||
- [帮助文档](https://justauth.wiki)中增加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://justauth.wiki)中修复[腾讯云登录]链接错误的问题
|
||||
- 升级
|
||||
- 升级相关依赖: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
|
||||
### 2019/11/12
|
||||
|
||||
- 修复[Issue#52](https://github.com/justauth/JustAuth/issues/52),解决AuthCallback异常的问题。请正在使用 `v1.13.0`的朋友升级到`v1.13.1`
|
||||
|
||||
## v1.13.0
|
||||
### 2019/11/01
|
||||
|
||||
- 集成“推特”
|
||||
- 完善文档
|
||||
|
||||
## v1.12.0
|
||||
### 2019/09/06
|
||||
|
||||
- 集成“美团”授权登录
|
||||
- 集成“饿了么”授权登录
|
||||
- 升级Fastjson依赖到1.2.60,预防[“Fastjson < 1.2.60 远程拒绝服务漏洞预警”](https://card.weibo.com/article/m/show/id/2309404413257925394542)
|
||||
- 添加Nutzboot版的demo
|
||||
- 提取公共的Source接口,支持自定义扩展第三方平台的授权登录,具体扩展例子可参考[AuthExtendRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java)
|
||||
|
||||
## v1.11.0
|
||||
### 2019/09/03
|
||||
|
||||
- 集成“Gitlab”授权登录
|
||||
|
||||
### 2019/09/02
|
||||
|
||||
- 集成“酷家乐”授权登录
|
||||
|
||||
## v1.10.1
|
||||
### 2019/08/17
|
||||
|
||||
- AuthUser添加构造函数,支持反序列化
|
||||
|
||||
### 2019/08/08
|
||||
|
||||
- 项目迁移到组织[justauth](https://github.com/justauth)
|
||||
|
||||
## v1.10.0
|
||||
### 2019/08/06
|
||||
|
||||
- 合并[PR-34](https://github.com/zhangyd-c/JustAuth/pull/34),添加StringUtil单元测试,修复bug
|
||||
- 合并[PR-35](https://github.com/zhangyd-c/JustAuth/pull/35),集成企业微信
|
||||
|
||||
### 2019/08/05
|
||||
|
||||
- 集成华为登录
|
||||
- 修改`AuthChecker#checkCode`方法,对于不同平台使用不同参数接受code的情况统一做处理
|
||||
|
||||
### 2019/08/03
|
||||
|
||||
合并github上[xkcoding](https://github.com/xkcoding) 的[pr#32](https://github.com/zhangyd-c/JustAuth/pull/32),抽取 cache 接口,方便用户自行集成 cache
|
||||
|
||||
### 2019/08/02
|
||||
|
||||
- 增加`AuthCache`配置类`AuthCacheConfig.java`,可以自定义缓存有效期以及是否开启定时任务
|
||||
- 去掉`slf4j`依赖,封装`Log.java`工具类
|
||||
- 规范测试类
|
||||
|
||||
## v1.9.5
|
||||
### 2019/07/31
|
||||
|
||||
`v1.9.4`版本发布失败,请升级到`1.9.5`版本!
|
||||
|
||||
由此给您带来的不便,敬请谅解!
|
||||
|
||||
## v1.9.4
|
||||
### 2019/07/30
|
||||
|
||||
1. 升级`hutool-http`版本到`v4.6.1`
|
||||
2. 去除`AuthCallback`中增加的默认的校验state的方法,挪到`AuthDefaultRequest`中做统一处理
|
||||
3. `alipay-sdk-java`依赖改为`provided`,如果需要使用支付宝登录,需要使用方手动引入相关依赖,具体操作方式,见项目WIKI;
|
||||
4. 规范注释
|
||||
|
||||
## v1.9.3
|
||||
### 2019/07/30
|
||||
|
||||
1. 规范注释
|
||||
2. 增加State缓存,`AuthCallback`中增加默认的校验state的方法
|
||||
3. 增加默认的state生成方法,参考`AuthStateUtils.java`和`UuidUtils.java`
|
||||
4. 升级`hutool-http`版本到`v4.6.0`
|
||||
5. 修复其他一些问题
|
||||
|
||||
### 2019/07/27
|
||||
|
||||
1. `IpUtils.getIp`改名为`IpUtils.getLocalIp`
|
||||
2. 规范注释
|
||||
|
||||
### 2019/07/25
|
||||
|
||||
1. `AuthConfig`类中去掉state参数
|
||||
2. 删除`AuthState`类
|
||||
3. 增加`authorize(String)`方法,并且使用`@Deprecated`标记`authorize()`方法
|
||||
|
||||
## v1.9.2
|
||||
### 2019/07/22
|
||||
1. 合并github上[xkcoding](https://github.com/xkcoding) 的[pr#26](https://github.com/zhangyd-c/JustAuth/pull/26),AuthConfig类添加lombok注解,方便 [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter) 直接使用
|
||||
|
||||
## v1.9.1
|
||||
### 2019/07/22
|
||||
1. 增加`stackoverflow`参数校验
|
||||
2. 解决`Pinterest`获取用户失败的问题
|
||||
3. 添加注释
|
||||
|
||||
## v1.9.0
|
||||
### 2019/07/19
|
||||
|
||||
1. 合并github上[@dyc12ii](https://github.com/dyc12ii) 的[pr#25](https://github.com/zhangyd-c/JustAuth/pull/25),升级fastjson版本至1.2.58,避免安全漏洞
|
||||
2. `AuthUserGender`枚举类挪到`enums`包下
|
||||
3. 删除`AuthBaiduErrorCode`和`AuthDingTalkErrorCode`枚举类
|
||||
4. 优化百度授权流程,增加refresh token的方法
|
||||
5. 优化`AuthConfig`、`AuthResponse`类,去掉不必要的lombonk注解,减少编译后的代码量
|
||||
6. 使用lombok注解优化枚举类
|
||||
7. `AuthQqRequest`增加refresh方法
|
||||
8. 修复google登录无法获取用户信息的问题
|
||||
9. 优化代码
|
||||
|
||||
### 2019/07/18
|
||||
|
||||
1. 合并github上[@pengisgood](https://github.com/pengisgood) 的[pr#19](https://github.com/zhangyd-c/JustAuth/pull/19),集成人人
|
||||
2. 合并github上[@pengisgood](https://github.com/pengisgood) 的[pr#20](https://github.com/zhangyd-c/JustAuth/pull/20),集成Pinterest
|
||||
3. 合并github上[@pengisgood](https://github.com/pengisgood) 的[pr#21](https://github.com/zhangyd-c/JustAuth/pull/21),集成StackOverflow
|
||||
4. 合并github上[@xkcoding](https://github.com/xkcoding) 的[pr#23](https://github.com/zhangyd-c/JustAuth/pull/23),重构代码、新增编辑器规范,规范PR代码风格
|
||||
|
||||
### 2019/07/17
|
||||
1. 优化代码
|
||||
2. 集成Teambition登录
|
||||
|
||||
### 2019/07/16
|
||||
1. 重构UrlBuilder类
|
||||
2. 将CSDN相关的类置为`Deprecated`,后续可能会删除,也可能一直保留。毕竟CSDN的openAPI已经不对外开放了。
|
||||
3. `BaseAuthRequest` 改名为 `AuthDefaultRequest`
|
||||
4. `ResponseStatus` 改名为 `AuthResponseStatus` 并且移动到 `me.zhyd.oauth.model`
|
||||
5. 合并github上[@xkcoding](https://github.com/xkcoding) 的[pr#18](https://github.com/zhangyd-c/JustAuth/pull/18),修复小米回调错误问题 同时 支持微信获取unionId
|
||||
|
||||
## v1.8.1
|
||||
### 2019/07/15
|
||||
1. 新增 `AuthState` 类,内置默认的state生成规则和校验规则
|
||||
|
||||
### 2019/07/12
|
||||
1. 合并[Braavos96](https://github.com/Braavos96)提交的[PR#16](https://github.com/zhangyd-c/JustAuth/pull/16)
|
||||
|
||||
## v1.8.0
|
||||
### 2019/06/28
|
||||
1. 修复百度登录获取不到token失效时间的问题
|
||||
2. 增加state参数校验,预防CSRF。**强烈建议启用state**!
|
||||
|
||||
### 2019/06/27
|
||||
1. 修复百度登录获取不到token失效时间的问题
|
||||
2. 增加state参数校验,预防CSRF。**强烈建议启用state**!
|
||||
3. 修改login方法的参数为AuthCallback,封装回调返回的参数
|
||||
4. 支持state参数
|
||||
5. 增加code和state参数校验
|
||||
|
||||
由于state安全问题,1.8.0以前的版本都有隐藏的CSRF漏洞问题,所以强烈建议正在使用JustAuth的朋友升级到1.8.0版本!
|
||||
|
||||
## v1.7.1
|
||||
### 2019/06/25
|
||||
qq授权登录时,需要获取`openId`作为`uuid`,在`1.6.1-beta`和`1.7.0`版本中,引入了`unionId`这一属性。获取`unionid`需要单独向qq团队**发送邮件**申请权限,鉴于这一申请权限的步骤比较麻烦(需要填写的内容比较多),所以在`AuthConfig`中增加了一个`unionId`属性,当为**true**时才会获取unionid,当为false时只获取openId。如果你需要该功能, 则在自行申请了相关权限后,将该属性置为true即可。关于unionId的参考链接:[UnionID介绍](http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D)
|
||||
|
||||
## v1.7.0
|
||||
### 2019/06/19
|
||||
1. 合并[xkcoding](https://github.com/xkcoding)提交的[PR](https://github.com/zhangyd-c/JustAuth/pull/14),重构了部分代码,jar包由原来的`130+kb`优化到现在的`110+kb`
|
||||
2. 合并[skqing](https://gitee.com/skqing)提交的[PR](https://gitee.com/yadong.zhang/JustAuth/pulls/3), 解决抖音登录失败问题
|
||||
|
||||
## v1.6.1-beta
|
||||
### 2019/06/18
|
||||
1. 解决Issue [#IY2HW](https://gitee.com/yadong.zhang/JustAuth/issues/IY2HW)
|
||||
2. 解决Issue [#IY2OH](https://gitee.com/yadong.zhang/JustAuth/issues/IY2OH)
|
||||
3. 解决Issue [#IY2FV](https://gitee.com/yadong.zhang/JustAuth/issues/IY2FV)
|
||||
4. 修复部分注释、拼写错误
|
||||
5. 解决Issue [#IY1QR](https://gitee.com/yadong.zhang/JustAuth/issues/IY1QR) 增加对Config属性的校验功能,主要校验redirect uri的合法性
|
||||
6. 合并[skqing](https://gitee.com/skqing)提交的[PR](https://gitee.com/yadong.zhang/JustAuth/pulls/2),解决一些BUG
|
||||
|
||||
## v1.6.0-beta
|
||||
### 2019/06/06
|
||||
1. 增加今日头条的授权登陆
|
||||
2. 发布1.6.0-beta版本,今日头条开发者暂时不能认证, 所以无法做测试,等测试通过后,正式发布release版本
|
||||
|
||||
## v1.5.0
|
||||
### 2019/05/28
|
||||
1. 增加小米账号和微软的授权登陆
|
||||
2. 发布1.5.0版本
|
||||
|
||||
## v1.4.0
|
||||
### 2019/05/26
|
||||
1. 增加抖音和Linkedin的授权登陆
|
||||
2. 修改部分图片命名
|
||||
3. 优化部分代码
|
||||
4. 修复`AuthSource`中腾讯云开发平台的拼写错误:`TENCEN_CLOUD`->`TENCENT_CLOUD`
|
||||
5. 修复支付宝登陆时用户名为空的问题
|
||||
|
||||
## v1.3.3
|
||||
### 2019/05/24
|
||||
1. 修复一些问题
|
||||
2. 升级api,在AuthUser中增加`uuid`属性,可以通过`uuid` + `source`唯一确定一个用户,此举解决了用户身份归属的问题。
|
||||
3. 发布1.3.3版本的jar包到公开仓库(1.3.2忘记发布了,( ╯□╰ ))
|
||||
4. 重要:经咨询官方客服得知,CSDN的授权开放平台已经下线,如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了
|
||||
|
||||
## v1.3.1
|
||||
### 2019/05/23
|
||||
1. 修复QQ登录的问题
|
||||
2. 发布1.3.1版本的jar包到公开仓库
|
||||
|
||||
## v1.3.0
|
||||
### 2019/05/21
|
||||
1. 新增google授权登录
|
||||
2. 新增facebook授权登录
|
||||
3. 发布1.3.0版本的jar包到公开仓库
|
||||
|
||||
## v1.1.0
|
||||
### 2019/05/18
|
||||
1. 发布1.1.0版本的jar包到公开仓库(支持qq和微信登录)
|
||||
2. 支持淘宝登录
|
||||
3. 修改`AuthUser.java`类中的`accessToken`属性,由原本的~~accessToken (String)~~改为`token (AuthToken)`
|
||||
4. 修复一些bug
|
||||
5. 发布1.2.0版本的jar包到公开仓库(支持淘宝登录)
|
||||
|
||||
### 2019/05/17
|
||||
1. 增加qq和微信的授权登录
|
||||
2. 修改getAccessToken方法的返回值
|
||||
|
||||
## v1.0.1
|
||||
### 2019/03/27
|
||||
集成 支付宝授权登录
|
||||
|
||||
## v1.0.0
|
||||
### 2019/03/25
|
||||
史上最全的整合第三方登录的工具,目前已支持Github、Gitee、微博、钉钉和百度、Coding、腾讯云开发者平台和OSChina登录。 Login, so easy!
|
||||
+12
-50
@@ -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%20Central-1.15.7%20beta.2-blue" ></img>
|
||||
<img src="https://img.shields.io/badge/Maven%20Central-1.16.1-blue" ></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,64 +15,26 @@
|
||||
<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%20Docs-1.15.7%20beta.1-orange" ></img>
|
||||
<img src="https://img.shields.io/badge/Api%20Docs-1.16.1-orange" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://justauth.wiki" title="参考文档">
|
||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/zhangyd-c/JustAuth">
|
||||
<img src="https://codecov.io/gh/zhangyd-c/JustAuth/branch/master/graph/badge.svg" />
|
||||
<a href="https://codecov.io/gh/justauth/JustAuth">
|
||||
<img src="https://codecov.io/gh/justauth/JustAuth/branch/master/graph/badge.svg?token=zYiAqd9aFz" />
|
||||
</a>
|
||||
<a href='https://gitee.com/yadong.zhang/JustAuth/stargazers'>
|
||||
<img src='https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=white' alt='star'></img>
|
||||
<img src='https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=gvp' alt='star'></img>
|
||||
</a>
|
||||
<a target="_blank" href='https://github.com/zhangyd-c/JustAuth'>
|
||||
<img src="https://img.shields.io/github/stars/zhangyd-c/JustAuth.svg?style=social" alt="github star"></img>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<center>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/tencentCloud.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信开放平台"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png" width="20"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/toutiao.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/teambition.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/renren.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信企业版"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png" width="20"></td>
|
||||
<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>
|
||||
<center><a href="https://justauth.wiki/#/?id=%E5%B7%B2%E9%9B%86%E6%88%90%E7%9A%84%E5%B9%B3%E5%8F%B0" target="_blank">查看更多</a></center>
|
||||
</center>
|
||||
-------------------------------------------------------------------------------
|
||||
<p align="center">
|
||||
<img src='./docs/media/75a3c076.png' alt='star'></img>
|
||||
</p>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@@ -97,7 +59,7 @@ These artifacts are available from Maven Central:
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.15.7-beta.2</version>
|
||||
<version>1.16.1</version>
|
||||
</dependency>
|
||||
```
|
||||
- Using JustAuth
|
||||
@@ -162,11 +124,11 @@ I look forward to your joining us.
|
||||
|
||||
## Contributors
|
||||
|
||||
[contributors](https://justauth.wiki/#/contributors)
|
||||
[contributors](https://justauth.wiki/contributors.html)
|
||||
|
||||
## Change Logs
|
||||
|
||||
[CHANGELOGS](https://justauth.wiki/#/update)
|
||||
[CHANGELOGS](https://justauth.wiki/update.html)
|
||||
|
||||
## Recommend
|
||||
|
||||
|
||||
@@ -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%20Central-1.15.7%20beta.2-blue" ></img>
|
||||
<img src="https://img.shields.io/badge/Maven%20Central-1.16.1-blue" ></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,64 +15,26 @@
|
||||
<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%20Docs-1.15.7%20beta.1-orange" ></img>
|
||||
<img src="https://img.shields.io/badge/Api%20Docs-1.16.1-orange" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://justauth.wiki" title="参考文档">
|
||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/zhangyd-c/JustAuth">
|
||||
<img src="https://codecov.io/gh/zhangyd-c/JustAuth/branch/master/graph/badge.svg" />
|
||||
<a href="https://codecov.io/gh/justauth/JustAuth">
|
||||
<img src="https://codecov.io/gh/justauth/JustAuth/branch/master/graph/badge.svg?token=zYiAqd9aFz" />
|
||||
</a>
|
||||
<a href='https://gitee.com/yadong.zhang/JustAuth/stargazers'>
|
||||
<img src='https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=white' alt='star'></img>
|
||||
<img src='https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=gvp' alt='star'></img>
|
||||
</a>
|
||||
<a target="_blank" href='https://github.com/zhangyd-c/JustAuth'>
|
||||
<img src="https://img.shields.io/github/stars/zhangyd-c/JustAuth.svg?style=social" alt="github star"></img>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<center>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/tencentCloud.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信开放平台"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png" width="20"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/toutiao.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/teambition.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/renren.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信企业版"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"></td>
|
||||
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png" width="20"></td>
|
||||
<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>
|
||||
<center><a href="https://justauth.wiki/#/?id=%E5%B7%B2%E9%9B%86%E6%88%90%E7%9A%84%E5%B9%B3%E5%8F%B0" target="_blank">查看更多</a></center>
|
||||
</center>
|
||||
-------------------------------------------------------------------------------
|
||||
<p align="center">
|
||||
<img src='./docs/media/75a3c076.png' alt='star'></img>
|
||||
</p>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@@ -84,7 +46,7 @@ QQ 群:230017570
|
||||
|
||||
JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具类库**,它可以让我们脱离繁琐的第三方登录 SDK,让登录变得**So easy!**
|
||||
|
||||
JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、Google、Facebook、Twitter、StackOverflow等国内外数十家第三方平台。更多请参考<a href="https://justauth.wiki/#/?id=%E5%B7%B2%E9%9B%86%E6%88%90%E7%9A%84%E5%B9%B3%E5%8F%B0" target="_blank">已集成的平台</a>
|
||||
JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、Google、Facebook、Twitter、StackOverflow等国内外数十家第三方平台。更多请参考<a href="https://justauth.wiki" target="_blank">已集成的平台</a>
|
||||
|
||||
## 有哪些特点?
|
||||
|
||||
@@ -93,11 +55,11 @@ JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、
|
||||
|
||||
## 有哪些功能?
|
||||
|
||||
- 集成国内外数十家第三方平台,实现快速接入。<a href="https://justauth.wiki/#/?id=%E5%B7%B2%E9%9B%86%E6%88%90%E7%9A%84%E5%B9%B3%E5%8F%B0" target="_blank">参考文档</a>
|
||||
- 自定义 State 缓存,支持各种分布式缓存组件。<a href="https://justauth.wiki/#/customize-the-state-cache" target="_blank">参考文档</a>
|
||||
- 自定义 OAuth 平台,更容易适配自有的 OAuth 服务。<a href="https://justauth.wiki/#/customize-the-oauth" target="_blank">参考文档</a>
|
||||
- 自定义 Http 实现,选择权完全交给开发者,不会单独依赖某一具体实现。<a href="https://justauth.wiki/#/customize-the-oauth" target="_blank">参考文档</a>
|
||||
- 自定义 Scope,支持更完善的授权体系。<a href="https://justauth.wiki" target="_blank">参考文档</a>
|
||||
- 集成国内外数十家第三方平台,实现快速接入。<a href="https://justauth.wiki/quickstart/how-to-use.html" target="_blank">参考文档</a>
|
||||
- 自定义 State 缓存,支持各种分布式缓存组件。<a href="https://justauth.wiki/features/customize-the-state-cache.html" target="_blank">参考文档</a>
|
||||
- 自定义 OAuth 平台,更容易适配自有的 OAuth 服务。<a href="https://justauth.wiki/features/customize-the-oauth.html" target="_blank">参考文档</a>
|
||||
- 自定义 Http 实现,选择权完全交给开发者,不会单独依赖某一具体实现。<a href="https://justauth.wiki/quickstart/how-to-use.html#%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F" target="_blank">参考文档</a>
|
||||
- 自定义 Scope,支持更完善的授权体系。<a href="https://justauth.wiki/features/customize-scopes.html" target="_blank">参考文档</a>
|
||||
- 更多...<a href="https://justauth.wiki" target="_blank">参考文档</a>
|
||||
|
||||
## 快速开始
|
||||
@@ -107,7 +69,7 @@ JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.15.7-beta.2</version>
|
||||
<version>1.16.1</version>
|
||||
</dependency>
|
||||
```
|
||||
- 调用api
|
||||
@@ -157,28 +119,52 @@ authRequest.login(callback);
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 赞助和支持
|
||||
|
||||
感谢以下赞助商的支持:
|
||||
|
||||
<a href="https://www.duohui.cn?utm_source=justauth" target="_blank"><img src="https://docs.duohui.cn/brand_source/img/std.svg" alt="多会 - 专业活动管理系统" style="height: 54px;" height="54px" /></a>
|
||||
|
||||
## JustAuth 的用户
|
||||
有很多公司、组织和个人把 JustAuth 用于学习、研究、生产环境和商业产品中,包括(但不限于):
|
||||

|
||||
|
||||
|
||||
怎么没有我?[加入]()
|
||||
怎么没有我?[登记](https://gitee.com/yadong.zhang/JustAuth/issues/IZ2T7)
|
||||
|
||||
## 开源推荐
|
||||
- `JAP` 开源的登录认证中间件: [https://gitee.com/fujieid/jap](https://gitee.com/fujieid/jap)
|
||||
- `spring-boot-demo` 深度学习并实战 spring boot 的项目: [https://github.com/xkcoding/spring-boot-demo](https://github.com/xkcoding/spring-boot-demo)
|
||||
- `mica` SpringBoot 微服务高效开发工具集: [https://github.com/lets-mica/mica](https://github.com/lets-mica/mica)
|
||||
- `pig` 微服务认证授权脚手架(架构师必备): [https://gitee.com/log4j/pig](https://gitee.com/log4j/pig)
|
||||
- `SpringBlade` 完整的线上解决方案(企业开发必备): [https://gitee.com/smallc/SpringBlade](https://gitee.com/smallc/SpringBlade)
|
||||
- `MaxKey` 马克思的钥匙,寓意是最大钥匙,是用户单点登录认证系统(Sigle Sign On System),OAuth 2.0/OpenID Connect、SAML 2.0、JWT、CAS等标准化的开放协议,使用JustAuth集成OAuth第三方认证。: [https://shimingxy.github.io/MaxKey/](https://shimingxy.github.io/MaxKey/)
|
||||
- `YurunOAuthLogin` PHP 第三方登录授权 SDK:[YurunOAuthLogin](https://gitee.com/yurunsoft/YurunOAuthLogin)
|
||||
- `sureness` 面向restful api的高性能认证鉴权框架:[sureness](https://github.com/usthe/sureness)
|
||||
|
||||
# 鸣谢
|
||||
## 鸣谢
|
||||
- 感谢 JetBrains 提供的免费开源 License:
|
||||
<img src="https://images.gitee.com/uploads/images/2020/0406/220236_f5275c90_5531506.png" alt="图片引用自lets-mica" style="float:left;">
|
||||
|
||||
<a href="https://www.producthunt.com/posts/justauth?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-justauth" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=196886&theme=dark" alt="JustAuth - Login, so easy! | Product Hunt Embed" style="width: 250px; height: 54px;" width="250px" height="54px" /></a>
|
||||
|
||||
## 其他
|
||||
- [CONTRIBUTORS](https://justauth.wiki/#/contributors)
|
||||
- [CHANGELOGS](https://justauth.wiki/#/update)
|
||||
- [PLAN](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK)
|
||||
- [CONTRIBUTORS](https://justauth.wiki/contributors.html)
|
||||
- [CHANGELOGS](https://justauth.wiki/update.html)
|
||||
- [PLAN](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK)
|
||||
|
||||
## 贡献者列表
|
||||
|
||||
[](https://whnb.wang)
|
||||
|
||||
## Stars 趋势
|
||||
|
||||
### Gitee
|
||||
|
||||
[](https://whnb.wang/yadong.zhang/JustAuth?e=604800)
|
||||
|
||||
### Github
|
||||
|
||||
[](https://starchart.cc/justauth/JustAuth)
|
||||
|
||||
### ProductHunt
|
||||
|
||||
<a href="https://www.producthunt.com/posts/justauth?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-justauth" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=196886&theme=dark" alt="JustAuth - Login, so easy! | Product Hunt Embed" style="width: 250px; height: 54px;" width="250px" height="54px" /></a>
|
||||
|
||||
@@ -25,8 +25,6 @@ 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
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.15.7-beta.2
|
||||
1.16.1
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 100 KiB |
@@ -15,6 +15,15 @@ case "$1" in
|
||||
'updv')
|
||||
bin/updVersion.sh $2
|
||||
;;
|
||||
'pd')
|
||||
bin/push-dev.sh
|
||||
;;
|
||||
'p')
|
||||
bin/push.sh
|
||||
;;
|
||||
'd')
|
||||
bin/deploy.sh
|
||||
;;
|
||||
*)
|
||||
help
|
||||
esac
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.15.7-beta.2</version>
|
||||
<version>1.16.1</version>
|
||||
|
||||
<name>JustAuth</name>
|
||||
<url>https://gitee.com/yadong.zhang/JustAuth</url>
|
||||
<description>
|
||||
史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、
|
||||
QQ、微信开放平台、微信公众平台、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、
|
||||
企业微信、酷家乐、Gitlab、美团、饿了么和推特等第三方平台的授权登录。
|
||||
Login, so easy!
|
||||
小而全而美的第三方登录开源组件。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信、酷家乐、Gitlab、美团、饿了么、推特、飞书、京东、阿里云、喜马拉雅、Amazon、Slack和Line等第三方平台的授权登录。 Login, so easy!
|
||||
</description>
|
||||
|
||||
<licenses>
|
||||
@@ -55,15 +52,15 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven-source.version>2.2.1</maven-source.version>
|
||||
<maven-compiler.version>3.8.1</maven-compiler.version>
|
||||
<maven-javadoc.version>3.1.0</maven-javadoc.version>
|
||||
<maven-javadoc.version>2.9.1</maven-javadoc.version>
|
||||
<cobertura-version>2.7</cobertura-version>
|
||||
<maven-surefire-version>2.20</maven-surefire-version>
|
||||
<maven-gpg-version>1.6</maven-gpg-version>
|
||||
<maven.test.skip>false</maven.test.skip>
|
||||
<simple-http.version>1.0.2</simple-http.version>
|
||||
<simple-http.version>1.0.3</simple-http.version>
|
||||
<lombok-version>1.18.10</lombok-version>
|
||||
<junit-version>4.11</junit-version>
|
||||
<fastjson-version>1.2.71</fastjson-version>
|
||||
<junit-version>4.13.1</junit-version>
|
||||
<fastjson-version>1.2.76</fastjson-version>
|
||||
<alipay-sdk-version>4.8.10.ALL</alipay-sdk-version>
|
||||
<jacoco-version>0.8.2</jacoco-version>
|
||||
</properties>
|
||||
@@ -138,6 +135,9 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<additionalparam>${javadoc.opts}</additionalparam>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -263,5 +263,15 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
<!-- 禁用 Javadoc 注释检查 -->
|
||||
<profile>
|
||||
<id>disable-javadoc-doclint</id>
|
||||
<activation>
|
||||
<jdk>[1.8,)</jdk>
|
||||
</activation>
|
||||
<properties>
|
||||
<javadoc.opts>-Xdoclint:none</javadoc.opts>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum AuthCacheScheduler {
|
||||
this.scheduler = new ScheduledThreadPoolExecutor(10, r -> new Thread(r, String.format("JustAuth-Task-%s", cacheTaskNumber.getAndIncrement())));
|
||||
}
|
||||
|
||||
private void shutdown() {
|
||||
public void shutdown() {
|
||||
if (null != scheduler) {
|
||||
this.scheduler.shutdown();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package me.zhyd.oauth.config;
|
||||
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
import lombok.*;
|
||||
import me.zhyd.oauth.enums.scope.AuthScope;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -66,13 +66,17 @@ public class AuthConfig {
|
||||
private String agentId;
|
||||
|
||||
/**
|
||||
* 使用 Coding 登录时,需要传该值。
|
||||
* 域名前缀。
|
||||
* <p>
|
||||
* 团队域名前缀,比如以“ https://justauth.coding.net/ ”为例,{@code codingGroupName} = justauth
|
||||
* 使用 Coding 登录和 Okta 登录时,需要传该值。
|
||||
* <p>
|
||||
* Coding 登录:团队域名前缀,比如以“ https://justauth.coding.net ”为例,{@code domainPrefix} = justauth
|
||||
* <p>
|
||||
* Okta 登录:Okta 账号域名前缀,比如以“ https://justauth.okta.com ”为例,{@code domainPrefix} = justauth
|
||||
*
|
||||
* @since 1.15.5
|
||||
* @since 1.16.0
|
||||
*/
|
||||
private String codingGroupName;
|
||||
private String domainPrefix;
|
||||
|
||||
/**
|
||||
* 针对国外服务可以单独设置代理
|
||||
@@ -110,4 +114,61 @@ public class AuthConfig {
|
||||
* @since 1.15.7
|
||||
*/
|
||||
private List<String> scopes;
|
||||
|
||||
/**
|
||||
* 设备ID, 设备唯一标识ID
|
||||
*
|
||||
* @since 1.15.8
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 喜马拉雅:客户端操作系统类型,1-iOS系统,2-Android系统,3-Web
|
||||
*
|
||||
* @since 1.15.9
|
||||
*/
|
||||
private Integer clientOsType;
|
||||
|
||||
/**
|
||||
* 喜马拉雅:客户端包名,如果 {@link AuthConfig#clientOsType} 为1或2时必填。对Android客户端是包名,对IOS客户端是Bundle ID
|
||||
*
|
||||
* @since 1.15.9
|
||||
*/
|
||||
private String packId;
|
||||
|
||||
/**
|
||||
* 是否开启 PKCE 模式,该配置仅用于支持 PKCE 模式的平台,针对无服务应用,不推荐使用隐式授权,推荐使用 PKCE 模式
|
||||
*
|
||||
* @since 1.15.9
|
||||
*/
|
||||
private boolean pkce;
|
||||
|
||||
/**
|
||||
* Okta 授权服务器的 ID, 默认为 default。如果要使用自定义授权服务,此处传实际的授权服务器 ID(一个随机串)
|
||||
* <p>
|
||||
* 创建自定义授权服务器,请参考:
|
||||
* <p>
|
||||
* ① https://developer.okta.com/docs/concepts/auth-servers
|
||||
* <p>
|
||||
* ② https://developer.okta.com/docs/guides/customize-authz-server
|
||||
*
|
||||
* @since 1.16.0
|
||||
*/
|
||||
private String authServerId;
|
||||
/**
|
||||
* 忽略校验 {@code redirectUri} 参数,默认不开启。当 {@code ignoreCheckRedirectUri} 为 {@code true} 时,
|
||||
* {@link me.zhyd.oauth.utils.AuthChecker#checkConfig(AuthConfig, AuthSource)} 将不会校验 {@code redirectUri} 的合法性。
|
||||
*
|
||||
* @since 1.16.1
|
||||
*/
|
||||
private boolean ignoreCheckRedirectUri;
|
||||
|
||||
/**
|
||||
* 适配 builder 模式 set 值的情况
|
||||
*
|
||||
* @return authServerId
|
||||
*/
|
||||
public String getAuthServerId() {
|
||||
return StringUtils.isEmpty(authServerId) ? "default" : authServerId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 钉钉
|
||||
* 钉钉扫码登录
|
||||
*/
|
||||
DINGTALK {
|
||||
@Override
|
||||
@@ -91,6 +91,25 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
return "https://oapi.dingtalk.com/sns/getuserinfo_bycode";
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 钉钉账号登录
|
||||
*/
|
||||
DINGTALK_ACCOUNT {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://oapi.dingtalk.com/connect/oauth2/sns_authorize";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return DINGTALK.accessToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return DINGTALK.userInfo();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 百度
|
||||
*/
|
||||
@@ -141,7 +160,7 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
},
|
||||
/**
|
||||
* Coding,
|
||||
*
|
||||
* <p>
|
||||
* 参考 https://help.coding.net/docs/project/open/oauth.html#%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83 中的说明,
|
||||
* 新版的 coding API 地址需要传入用户团队名,这儿使用动态参数,方便在 request 中使用
|
||||
*/
|
||||
@@ -315,17 +334,17 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
FACEBOOK {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://www.facebook.com/v3.3/dialog/oauth";
|
||||
return "https://www.facebook.com/v10.0/dialog/oauth";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://graph.facebook.com/v3.3/oauth/access_token";
|
||||
return "https://graph.facebook.com/v10.0/oauth/access_token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://graph.facebook.com/v3.3/me";
|
||||
return "https://graph.facebook.com/v10.0/me";
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -561,7 +580,7 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
},
|
||||
|
||||
/**
|
||||
* 企业微信
|
||||
* 企业微信二维码登录
|
||||
*
|
||||
* @since 1.10.0
|
||||
*/
|
||||
@@ -582,6 +601,26 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 企业微信网页登录
|
||||
*/
|
||||
WECHAT_ENTERPRISE_WEB {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://open.weixin.qq.com/connect/oauth2/authorize";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 酷家乐
|
||||
*
|
||||
@@ -710,30 +749,31 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
},
|
||||
|
||||
/**
|
||||
* 飞书
|
||||
* 注意:该平台暂时存在问题,请不要使用。待修复完成后会重新发版
|
||||
* 飞书平台,企业自建应用授权登录,原逻辑由 beacon 集成于 1.14.0 版,但最新的飞书 api 已修改,并且飞书平台一直为 {@code Deprecated} 状态
|
||||
* <p>
|
||||
* 所以,最终修改该平台的实际发布版本为 1.15.9
|
||||
*
|
||||
* @since 1.14.0
|
||||
* @since 1.15.9
|
||||
*/
|
||||
FEISHU {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://open.feishu.cn/connect/qrconnect/page/sso/";
|
||||
return "https://open.feishu.cn/open-apis/authen/v1/index";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://open.feishu.cn/connect/qrconnect/oauth2/access_token/";
|
||||
return "https://open.feishu.cn/open-apis/authen/v1/access_token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://open.feishu.cn/connect/qrconnect/oauth2/user_info/";
|
||||
return "https://open.feishu.cn/open-apis/authen/v1/user_info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refresh() {
|
||||
return "https://open.feishu.cn/connect/qrconnect/oauth2/access_token/";
|
||||
return "https://open.feishu.cn/open-apis/authen/v1/refresh_access_token";
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -786,6 +826,154 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
public String refresh() {
|
||||
return "https://oauth.aliyun.com/v1/token";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 喜马拉雅
|
||||
*/
|
||||
XMLY {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://api.ximalaya.com/oauth2/js/authorize";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://api.ximalaya.com/oauth2/v2/access_token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://api.ximalaya.com/profile/user_info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refresh() {
|
||||
return "https://oauth.aliyun.com/v1/token";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Amazon
|
||||
*
|
||||
* @since 1.16.0
|
||||
*/
|
||||
AMAZON {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://www.amazon.com/ap/oa";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://api.amazon.com/auth/o2/token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://api.amazon.com/user/profile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refresh() {
|
||||
return "https://api.amazon.com/auth/o2/token";
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Slack
|
||||
*
|
||||
* @since 1.16.0
|
||||
*/
|
||||
SLACK {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://slack.com/oauth/v2/authorize";
|
||||
}
|
||||
|
||||
/**
|
||||
* 该 API 获取到的是 access token
|
||||
*
|
||||
* https://slack.com/api/oauth.token 获取到的是 workspace token
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://slack.com/api/oauth.v2.access";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://slack.com/api/users.info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String revoke() {
|
||||
return "https://slack.com/api/auth.revoke";
|
||||
}
|
||||
},
|
||||
/**
|
||||
* line
|
||||
*
|
||||
* @since 1.16.0
|
||||
*/
|
||||
LINE {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://access.line.me/oauth2/v2.1/authorize";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://api.line.me/oauth2/v2.1/token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://api.line.me/v2/profile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refresh() {
|
||||
return "https://api.line.me/oauth2/v2.1/token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String revoke() {
|
||||
return "https://api.line.me/oauth2/v2.1/revoke";
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Okta,
|
||||
* <p>
|
||||
* 团队/组织的域名不同,此处通过配置动态组装
|
||||
*
|
||||
* @since 1.16.0
|
||||
*/
|
||||
OKTA {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://%s.okta.com/oauth2/%s/v1/authorize";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://%s.okta.com/oauth2/%s/v1/token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refresh() {
|
||||
return "https://%s.okta.com/oauth2/%s/v1/token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://%s.okta.com/oauth2/%s/v1/userinfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String revoke() {
|
||||
return "https://%s.okta.com/oauth2/%s/v1/revoke";
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import me.zhyd.oauth.log.Log;
|
||||
|
||||
/**
|
||||
* JustAuth 日志配置类
|
||||
*
|
||||
* @author HeJin
|
||||
*/
|
||||
public class JustAuthLogConfig {
|
||||
|
||||
/**
|
||||
* 设置日志级别
|
||||
*
|
||||
* @param level 日志级别
|
||||
*/
|
||||
public static void setLevel(Log.Level level) {
|
||||
Log.Config.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭日志
|
||||
*/
|
||||
public static void disable() {
|
||||
Log.Config.enable = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启日志
|
||||
*/
|
||||
public static void enable() {
|
||||
Log.Config.enable = true;
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,10 @@ public enum AuthResponseStatus {
|
||||
ILLEGAL_CODE(5008, "Illegal code"),
|
||||
ILLEGAL_STATUS(5009, "Illegal state"),
|
||||
REQUIRED_REFRESH_TOKEN(5010, "The refresh token is required; it must not be null"),
|
||||
ILLEGAL_TOKEN(5011, "Invalid token"),
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private final int code;
|
||||
private final String msg;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package me.zhyd.oauth.enums.scope;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Amazon平台 OAuth 授权范围
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
* @since 1.16.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AuthAmazonScope implements AuthScope {
|
||||
|
||||
/**
|
||||
* {@code scope} 含义,以{@code description} 为准
|
||||
*/
|
||||
R_LITEPROFILE("profile", "The profile scope includes a user's name and email address", true),
|
||||
R_EMAILADDRESS("profile:user_id", "The profile:user_id scope only includes the user_id field of the profile", true),
|
||||
W_MEMBER_SOCIAL("postal_code", "This includes the user's zip/postal code number from their primary shipping address", true);
|
||||
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 边度平台 OAuth 授权范围
|
||||
* 百度平台 OAuth 授权范围
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
@@ -23,8 +23,8 @@ public enum AuthBaiduScope implements AuthScope {
|
||||
PUBLIC("public", "可以访问公共的开放API。", false),
|
||||
HAO123("hao123", "可以访问Hao123 提供的开放API接口。该权限需要申请开通,请将具体的理由和用途发邮件给tuangou@baidu.com。", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public enum AuthCodingScope implements AuthScope {
|
||||
PROJECT_DEPOT("project:depot", "完整的仓库控制权限", false),
|
||||
PROJECT_WIKI("project:wiki", "授权读取与操作 wiki", false),
|
||||
;
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package me.zhyd.oauth.enums.scope;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 抖音平台 OAuth 授权范围
|
||||
*
|
||||
* https://open.douyin.com/platform/doc/6855240178122983437
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
* @since 1.16.1
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AuthDouyinScope implements AuthScope {
|
||||
|
||||
/**
|
||||
* 无需申请 默认开启
|
||||
*/
|
||||
USER_INFO("user_info", "返回抖音用户公开信息", true),
|
||||
/**
|
||||
* 无需申请 默认开启
|
||||
*/
|
||||
AWEME_SHARE("aweme.share", "抖音分享", false),
|
||||
/**
|
||||
* 普通权限,管理中心申请
|
||||
*/
|
||||
IM_SHARE("im.share", "分享给抖音好友", false),
|
||||
RENEW_REFRESH_TOKEN("renew_refresh_token", "授权有效期动态续期", false),
|
||||
FOLLOWING_LIST("following.list", "获取该用户的关注列表", false),
|
||||
FANS_LIST("fans.list", "获取该用户的粉丝列表", false),
|
||||
VIDEO_CREATE("video.create", "视频发布及管理", false),
|
||||
VIDEO_DELETE("video.delete", "删除内容", false),
|
||||
VIDEO_DATA("video.data", "查询授权用户的抖音视频数据", false),
|
||||
VIDEO_LIST("video.list", "查询特定抖音视频的视频数据", false),
|
||||
/**
|
||||
* 特殊权限 默认关闭 管理中心申请
|
||||
*/
|
||||
SHARE_WITH_SOURCE("share_with_source", "分享携带来源标签,用户可点击标签进入转化页", false),
|
||||
MOBILE("mobile", "用抖音帐号登录第三方平台,获得用户在抖音上的手机号码", false),
|
||||
MOBILE_ALERT("mobile_alert", "用抖音帐号登录第三方平台,获得用户在抖音上的手机号码", false),
|
||||
VIDEO_SEARCH("video.search", "关键词视频管理", false),
|
||||
POI_SEARCH("poi.search", "查询POI信息", false),
|
||||
LOGIN_ID("login_id", "静默授权直接获取该用户的open id", false),
|
||||
/**
|
||||
* 抖音数据权限, 默认关闭, 管理中心申请
|
||||
*/
|
||||
DATA_EXTERNAL_USER("data.external.user", "查询用户的获赞、评论、分享,主页访问等相关数据", false),
|
||||
DATA_EXTERNAL_ITEM("data.external.item", "查询作品的获赞,评论,分享等相关数据", false),
|
||||
FANS_DATA("fans.data", "获取用户粉丝画像数据", false),
|
||||
HOTSEARCH("hotsearch", "获取抖音热门内容", false),
|
||||
STAR_TOP_SCORE_DISPLAY("star_top_score_display", "星图达人与达人对应各指数评估分,以及星图6大热门维度下的达人榜单", false),
|
||||
STAR_TOPS("star_tops", "星图达人与达人对应各指数评估分,以及星图6大热门维度下的达人榜单", false),
|
||||
STAR_AUTHOR_SCORE_DISPLAY("star_author_score_display", "星图达人与达人对应各指数评估分,以及星图6大热门维度下的达人榜单", false),
|
||||
notes("data.external.sdk_share", "获取用户通过分享SDK分享视频数据", false),
|
||||
/**
|
||||
* 定向开通 默认关闭 定向开通
|
||||
*/
|
||||
DISCOVERY_ENT("discovery.ent", "查询抖音电影榜、抖音剧集榜、抖音综艺榜数据", false),
|
||||
;
|
||||
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -17,24 +17,24 @@ public enum AuthFacebookScope implements AuthScope {
|
||||
/**
|
||||
* {@code scope} 含义,以{@code description} 为准
|
||||
*/
|
||||
EMAIL("email", "获取用户的邮箱", false),
|
||||
USER_AGE_RANGE("user_age_range", "允许应用程序访问用户的年龄范围", false),
|
||||
USER_BIRTHDAY("user_birthday", "获取用户的生日", false),
|
||||
USER_FRIENDS("user_friends", "获取用户的好友列表", false),
|
||||
USER_GENDER("user_gender", "获取用户的性别", false),
|
||||
USER_HOMETOWN("user_hometown", "获取用户的家乡信息", false),
|
||||
USER_LIKES("user_likes", "获取用户的喜欢列表", false),
|
||||
USER_LINK("user_link", "获取用户的个人链接", false),
|
||||
USER_LOCATION("user_location", "获取用户的位置信息", false),
|
||||
USER_PHOTOS("user_photos", "获取用户的相册信息", false),
|
||||
USER_POSTS("user_posts", "获取用户发布的内容", false),
|
||||
USER_VIDEOS("user_videos", "获取用户上传的视频信息", false),
|
||||
EMAIL("email", "获取用户的邮箱", true),
|
||||
USER_AGE_RANGE("user_age_range", "允许应用程序访问用户的年龄范围", true),
|
||||
USER_BIRTHDAY("user_birthday", "获取用户的生日", true),
|
||||
USER_FRIENDS("user_friends", "获取用户的好友列表", true),
|
||||
USER_GENDER("user_gender", "获取用户的性别", true),
|
||||
USER_HOMETOWN("user_hometown", "获取用户的家乡信息", true),
|
||||
USER_LIKES("user_likes", "获取用户的喜欢列表", true),
|
||||
USER_LINK("user_link", "获取用户的个人链接", true),
|
||||
USER_LOCATION("user_location", "获取用户的位置信息", true),
|
||||
USER_PHOTOS("user_photos", "获取用户的相册信息", true),
|
||||
USER_POSTS("user_posts", "获取用户发布的内容", true),
|
||||
USER_VIDEOS("user_videos", "获取用户上传的视频信息", true),
|
||||
GROUPS_ACCESS_MEMBER_INFO("groups_access_member_info", "获取公开的群组成员信息", false),
|
||||
PUBLISH_TO_GROUPS("publish_to_groups", "授权您的应用程序代表某人将内容发布到组中,前提是他们已经授予您的应用程序访问权限", false),
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public enum AuthGiteeScope implements AuthScope {
|
||||
ENTERPRISES("enterprises", "查看、管理用户的企业以及成员", false),
|
||||
EMAILS("emails", "查看用户的个人邮箱信息", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 边度平台 OAuth 授权范围
|
||||
* Github平台 OAuth 授权范围
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
@@ -47,8 +47,8 @@ public enum AuthGithubScope implements AuthScope {
|
||||
READ_GPG_KEY("read:gpg_key", "List and view details for GPG keys.", false),
|
||||
WORKFLOW("workflow", "Grants the ability to add and update GitHub Actions workflow files. Workflow files can be committed without this scope if the same file (with both the same path and contents) exists on another branch in the same repository.", false),
|
||||
;
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ public enum AuthGitlabScope implements AuthScope {
|
||||
API("api", "Grants complete read/write access to the API, including all groups and projects, the container registry, and the package registry.", false),
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -281,9 +281,9 @@ public enum AuthGoogleScope implements AuthScope {
|
||||
ADEXCHANGE_BUYER("https://www.googleapis.com/auth/adexchange.buyer", "Manage your Ad Exchange buyer account configuration", false),
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
|
||||
public static List<String> getAdminDirectoryScopes() {
|
||||
|
||||
@@ -39,8 +39,8 @@ public enum AuthHuaweiScope implements AuthScope {
|
||||
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public enum AuthJdScope implements AuthScope {
|
||||
*/
|
||||
SNSAPI_BASE("snsapi_base", "基础授权", true);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ public enum AuthKujialeScope implements AuthScope {
|
||||
GET_DESIGN("get_design", "获取指定方案详情", false),
|
||||
GET_BUDGET_LIST("get_budget_list", "获取清单预算概览数据", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package me.zhyd.oauth.enums.scope;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Line 平台 OAuth 授权范围
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AuthLineScope implements AuthScope {
|
||||
|
||||
/**
|
||||
* {@code scope} 含义,以{@code description} 为准
|
||||
*/
|
||||
|
||||
PROFILE("profile", "Get profile details", true),
|
||||
OPENID("openid", "Get id token", true),
|
||||
EMAIL("email", "Get email (separate authorization required)", false);
|
||||
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -36,8 +36,8 @@ public enum AuthLinkedinScope implements AuthScope {
|
||||
W_ORGANIZATION_SOCIAL("w_organization_social", "Post, comment and like posts on your organization's behalf", false),
|
||||
W_SHARE("w_share", "Post updates to LinkedIn as you", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ public enum AuthMiScope implements AuthScope {
|
||||
OPENID("user/openIdV2", "获取用户的OpenID", true),
|
||||
PHONE_EMAIL("user/phoneAndEmail", "获取用户的手机号和邮箱", true);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public enum AuthMicrosoftScope implements AuthScope {
|
||||
NOTES_READWRITE_ALL("Notes.ReadWrite.All", "允许应用读取、共享和修改已登录用户在组织中有权访问的 OneNote 笔记本", false),
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package me.zhyd.oauth.enums.scope;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Okta 平台 OAuth 授权范围
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AuthOktaScope implements AuthScope {
|
||||
|
||||
/**
|
||||
* {@code scope} 含义,以{@code description} 为准
|
||||
*/
|
||||
OPENID("openid", "Signals that a request is an OpenID request.", true),
|
||||
PROFILE("profile", "The exact data varies based on what profile information you have provided, such as: name, time zone, picture, or birthday.", true),
|
||||
EMAIL("email", "This allows the app to view your email address.", true),
|
||||
ADDRESS("address", "This allows the app to view your address, such as: street address, city, state, and zip code.", true),
|
||||
PHONE("phone", "This allows the app to view your phone number.", true),
|
||||
OFFLINE_ACCESS("offline_access", "This keeps you signed in to the app, even when you are not using it.", true),
|
||||
OKTA_USERS_MANAGE("okta.users.manage", "Allows the app to create and manage users and read all profile and credential information for users", false),
|
||||
OKTA_USERS_READ("okta.users.read", "Allows the app to read any user's profile and credential information", false),
|
||||
OKTA_USERS_MANAGE_SELF("okta.users.manage.self", "Allows the app to manage the currently signed-in user's profile. Currently only supports user profile attribute updates.", false),
|
||||
OKTA_USERS_READ_SELF("okta.users.read.self", "Allows the app to read the currently signed-in user's profile and credential information", false),
|
||||
OKTA_APPS_MANAGE("okta.apps.manage", "Allows the app to create and manage Apps in your Okta organization", false),
|
||||
OKTA_APPS_READ("okta.apps.read", "Allows the app to read information about Apps in your Okta organization", false),
|
||||
OKTA_AUTHORIZATIONSERVERS_MANAGE("okta.authorizationServers.manage", "Allows the app to manage authorization servers", false),
|
||||
OKTA_AUTHORIZATIONSERVERS_READ("okta.authorizationServers.read", "Allows the app to read authorization server information", false),
|
||||
OKTA_CLIENTS_MANAGE("okta.clients.manage", "Allows the app to manage all OAuth/OIDC clients and to create new clients", false),
|
||||
OKTA_CLIENTS_READ("okta.clients.read", "Allows the app to read information for all OAuth/OIDC clients", false),
|
||||
OKTA_CLIENTS_REGISTER("okta.clients.register", "Allows the app to register (create) new OAuth/OIDC clients (but not read information about existing clients)", false),
|
||||
OKTA_EVENTHOOKS_MANAGE("okta.eventHooks.manage", "Allows the app to create and manage Event Hooks in your Okta organization", false),
|
||||
OKTA_EVENTHOOKS_READ("okta.eventHooks.read", "Allows the app to read information about Event Hooks in your Okta organization", false),
|
||||
OKTA_FACTORS_MANAGE("okta.factors.manage", "Allows the app to manage all admin operations for org factors (for example, activate, deactive, read)", false),
|
||||
OKTA_FACTORS_READ("okta.factors.read", "Allows the app to read org factors information", false),
|
||||
OKTA_GROUPS_MANAGE("okta.groups.manage", "Allows the app to manage groups in your Okta organization", false),
|
||||
OKTA_GROUPS_READ("okta.groups.read", "Allows the app to read information about groups and their members in your Okta organization", false),
|
||||
OKTA_IDPS_MANAGE("okta.idps.manage", "Allows the app to create and manage Identity Providers in your Okta organization", false),
|
||||
OKTA_IDPS_READ("okta.idps.read", "Allows the app to read information about Identity Providers in your Okta organization", false),
|
||||
OKTA_INLINEHOOKS_MANAGE("okta.inlineHooks.manage", "Allows the app to create and manage Inline Hooks in your Okta organization.", false),
|
||||
OKTA_INLINEHOOKS_READ("okta.inlineHooks.read", "Allows the app to read information about Inline Hooks in your Okta organization.", false),
|
||||
OKTA_LINKEDOBJECTS_MANAGE("okta.linkedObjects.manage", "Allows the app to manage Linked Object definitions in your Okta organization.", false),
|
||||
OKTA_LINKEDOBJECTS_READ("okta.linkedObjects.read", "Allows the app to read Linked Object definitions in your Okta organization.", false),
|
||||
OKTA_LOGS_READ("okta.logs.read", "Allows the app to read information about System Log entries in your Okta organization", false),
|
||||
OKTA_ROLES_MANAGE("okta.roles.manage", "Allows the app to create and manage Administrator Roles in your Okta organization", false),
|
||||
OKTA_ROLES_READ("okta.roles.read", "Allows the app to read information about Administrator Roles in your Okta organization", false),
|
||||
OKTA_SCHEMAS_MANAGE("okta.schemas.manage", "Allows the app to create and manage Schemas in your Okta organization", false),
|
||||
OKTA_SCHEMAS_READ("okta.schemas.read", "Allows the app to read information about Schemas in your Okta organization", false),
|
||||
OKTA_SESSIONS_MANAGE("okta.sessions.manage", "Allows the app to manage all sessions in your Okta organization", false),
|
||||
OKTA_SESSIONS_READ("okta.sessions.read", "Allows the app to read all sessions in your Okta organization", false),
|
||||
OKTA_TEMPLATES_MANAGE("okta.templates.manage", "Allows the app to manage all custom templates in your Okta organization", false),
|
||||
OKTA_TEMPLATES_READ("okta.templates.read", "Allows the app to read all custom templates in your Okta organization", false),
|
||||
OKTA_TRUSTEDORIGINS_MANAGE("okta.trustedOrigins.manage", "Allows the app to manage all Trusted Origins in your Okta organization", false),
|
||||
OKTA_TRUSTEDORIGINS_READ("okta.trustedOrigins.read", "Allows the app to read all Trusted Origins in your Okta organization", false),
|
||||
OKTA_POLICIES_MANAGE("okta.policies.manage", "Allows the app to manage Policies in your Okta organization", false),
|
||||
OKTA_POLICIES_READ("okta.policies.read", "Allows the app to read information about Policies in your Okta organization", false),;
|
||||
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -23,8 +23,8 @@ public enum AuthPinterestScope implements AuthScope {
|
||||
WRITE_RELATIONSHIPS("write_relationships", "Use PATCH, POST and DELETE methods on a user’s follows and followers (on boards, users and interests).", false),
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public enum AuthQqScope implements AuthScope {
|
||||
ADD_ALBUM("add_album", "在用户的空间相册里,创建一个新的个人相册", false),
|
||||
LIST_PHOTO("list_photo", "获取用户QQ空间相册中的照片列表", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public enum AuthRenrenScope implements AuthScope {
|
||||
ADMIN_PAGE("admin_page", "以用户的身份,管理其可以管理的公共主页的权限。", false),
|
||||
;
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package me.zhyd.oauth.enums.scope;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Slack 平台 OAuth 授权范围
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AuthSlackScope implements AuthScope {
|
||||
|
||||
/**
|
||||
* {@code scope} 含义,以{@code description} 为准
|
||||
*/
|
||||
USERS_PROFILE_READ("users.profile:read", "View profile details about people in a workspace", true),
|
||||
USERS_READ("users:read", "View people in a workspace", true),
|
||||
USERS_READ_EMAIL("users:read.email", "View email addresses of people in a workspace", true),
|
||||
USERS_PROFILE_WRITE("users.profile:write", "Edit a user’s profile information and status", false),
|
||||
USERS_PROFILE_WRITE_USER("users.profile:write:user", "Change the user's profile fields", false),
|
||||
USERS_WRITE("users:write", "Set presence for your slack app", false),
|
||||
ADMIN("admin", "Administer a workspace", false),
|
||||
ADMIN_ANALYTICS_READ("admin.analytics:read", "Access analytics data about the organization", false),
|
||||
ADMIN_APPS_READ("admin.apps:read", "View apps and app requests in a workspace", false),
|
||||
ADMIN_APPS_WRITE("admin.apps:write", "Manage apps in a workspace", false),
|
||||
ADMIN_BARRIERS_READ("admin.barriers:read", "Read information barriers in the organization", false),
|
||||
ADMIN_BARRIERS_WRITE("admin.barriers:write", "Manage information barriers in the organization", false),
|
||||
ADMIN_CONVERSATIONS_READ("admin.conversations:read", "View the channel’s member list, topic, purpose and channel name", false),
|
||||
ADMIN_CONVERSATIONS_WRITE("admin.conversations:write", "Start a new conversation, modify a conversation and modify channel details", false),
|
||||
ADMIN_INVITES_READ("admin.invites:read", "Gain information about invite requests in a Grid organization.", false),
|
||||
ADMIN_INVITES_WRITE("admin.invites:write", "Approve or deny invite requests in a Grid organization.", false),
|
||||
ADMIN_TEAMS_READ("admin.teams:read", "Access information about a workspace", false),
|
||||
ADMIN_TEAMS_WRITE("admin.teams:write", "Make changes to a workspace", false),
|
||||
ADMIN_USERGROUPS_READ("admin.usergroups:read", "Access information about user groups", false),
|
||||
ADMIN_USERGROUPS_WRITE("admin.usergroups:write", "Make changes to your usergroups", false),
|
||||
ADMIN_USERS_READ("admin.users:read", "Access a workspace’s profile information", false),
|
||||
ADMIN_USERS_WRITE("admin.users:write", "Modify account information", false),
|
||||
APP_MENTIONS_READ("app_mentions:read", "View messages that directly mention @your_slack_app in conversations that the app is in", false),
|
||||
AUDITLOGS_READ("auditlogs:read", "View events from all workspaces, channels and users (Enterprise Grid only)", false),
|
||||
BOT("bot", "Add the ability for people to direct message or mention @your_slack_app", false),
|
||||
CALLS_READ("calls:read", "View information about ongoing and past calls", false),
|
||||
CALLS_WRITE("calls:write", "Start and manage calls in a workspace", false),
|
||||
CHANNELS_HISTORY("channels:history", "View messages and other content in public channels that your slack app has been added to", false),
|
||||
CHANNELS_JOIN("channels:join", "Join public channels in a workspace", false),
|
||||
CHANNELS_MANAGE("channels:manage", "Manage public channels that your slack app has been added to and create new ones", false),
|
||||
CHANNELS_READ("channels:read", "View basic information about public channels in a workspace", false),
|
||||
CHANNELS_WRITE("channels:write", "Manage a user’s public channels and create new ones on a user’s behalf", false),
|
||||
CHAT_WRITE("chat:write", "Post messages in approved channels & conversations", false),
|
||||
CHAT_WRITE_CUSTOMIZE("chat:write.customize", "Send messages as @your_slack_app with a customized username and avatar", false),
|
||||
CHAT_WRITE_PUBLIC("chat:write.public", "Send messages to channels @your_slack_app isn't a member of", false),
|
||||
CHAT_WRITE_BOT("chat:write:bot", "Send messages as your slack app", false),
|
||||
CHAT_WRITE_USER("chat:write:user", "Send messages on a user’s behalf", false),
|
||||
CLIENT("client", "Receive all events from a workspace in real time", false),
|
||||
COMMANDS("commands", "Add shortcuts and/or slash commands that people can use", false),
|
||||
CONVERSATIONS_HISTORY("conversations:history", "Deprecated: Retrieve conversation history for legacy workspace apps", false),
|
||||
CONVERSATIONS_READ("conversations:read", "Deprecated: Retrieve information on conversations for legacy workspace apps", false),
|
||||
CONVERSATIONS_WRITE("conversations:write", "Deprecated: Edit conversation attributes for legacy workspace apps", false),
|
||||
DND_READ("dnd:read", "View Do Not Disturb settings for people in a workspace", false),
|
||||
DND_WRITE("dnd:write", "Edit a user’s Do Not Disturb settings", false),
|
||||
DND_WRITE_USER("dnd:write:user", "Change the user's Do Not Disturb settings", false),
|
||||
EMOJI_READ("emoji:read", "View custom emoji in a workspace", false),
|
||||
FILES_READ("files:read", "View files shared in channels and conversations that your slack app has been added to", false),
|
||||
FILES_WRITE("files:write", "Upload, edit, and delete files as your slack app", false),
|
||||
FILES_WRITE_USER("files:write:user", "Upload, edit, and delete files as your slack app", false),
|
||||
GROUPS_HISTORY("groups:history", "View messages and other content in private channels that your slack app has been added to", false),
|
||||
GROUPS_READ("groups:read", "View basic information about private channels that your slack app has been added to", false),
|
||||
GROUPS_WRITE("groups:write", "Manage private channels that your slack app has been added to and create new ones", false),
|
||||
IDENTIFY("identify", "View information about a user’s identity", false),
|
||||
IDENTITY_AVATAR("identity.avatar", "View a user’s Slack avatar", false),
|
||||
IDENTITY_AVATAR_READ_USER("identity.avatar:read:user", "View the user's profile picture", false),
|
||||
IDENTITY_BASIC("identity.basic", "View information about a user’s identity", false),
|
||||
IDENTITY_EMAIL("identity.email", "View a user’s email address", false),
|
||||
IDENTITY_EMAIL_READ_USER("identity.email:read:user", "This scope is not yet described.", false),
|
||||
IDENTITY_TEAM("identity.team", "View a user’s Slack workspace name", false),
|
||||
IDENTITY_TEAM_READ_USER("identity.team:read:user", "View the workspace's name, domain, and icon", false),
|
||||
IDENTITY_READ_USER("identity:read:user", "This scope is not yet described.", false),
|
||||
IM_HISTORY("im:history", "View messages and other content in direct messages that your slack app has been added to", false),
|
||||
IM_READ("im:read", "View basic information about direct messages that your slack app has been added to", false),
|
||||
IM_WRITE("im:write", "Start direct messages with people", false),
|
||||
INCOMING_WEBHOOK("incoming-webhook", "Create one-way webhooks to post messages to a specific channel", false),
|
||||
LINKS_READ("links:read", "View URLs in messages", false),
|
||||
LINKS_WRITE("links:write", "Show previews of URLs in messages", false),
|
||||
MPIM_HISTORY("mpim:history", "View messages and other content in group direct messages that your slack app has been added to", false),
|
||||
MPIM_READ("mpim:read", "View basic information about group direct messages that your slack app has been added to", false),
|
||||
MPIM_WRITE("mpim:write", "Start group direct messages with people", false),
|
||||
NONE("none", "Execute methods without needing a scope", false),
|
||||
PINS_READ("pins:read", "View pinned content in channels and conversations that your slack app has been added to", false),
|
||||
PINS_WRITE("pins:write", "Add and remove pinned messages and files", false),
|
||||
POST("post", "Post messages to a workspace", false),
|
||||
REACTIONS_READ("reactions:read", "View emoji reactions and their associated content in channels and conversations that your slack app has been added to", false),
|
||||
REACTIONS_WRITE("reactions:write", "Add and edit emoji reactions", false),
|
||||
READ("read", "View all content in a workspace", false),
|
||||
REMINDERS_READ("reminders:read", "View reminders created by your slack app", false),
|
||||
REMINDERS_READ_USER("reminders:read:user", "Access reminders created by a user or for a user", false),
|
||||
REMINDERS_WRITE("reminders:write", "Add, remove, or mark reminders as complete", false),
|
||||
REMINDERS_WRITE_USER("reminders:write:user", "Add, remove, or complete reminders for the user", false),
|
||||
REMOTE_FILES_READ("remote_files:read", "View remote files added by the app in a workspace", false),
|
||||
REMOTE_FILES_SHARE("remote_files:share", "Share remote files on a user’s behalf", false),
|
||||
REMOTE_FILES_WRITE("remote_files:write", "Add, edit, and delete remote files on a user’s behalf", false),
|
||||
SEARCH_READ("search:read", "Search a workspace’s content", false),
|
||||
STARS_READ("stars:read", "View messages and files that your slack app has starred", false),
|
||||
STARS_WRITE("stars:write", "Add or remove stars", false),
|
||||
TEAM_READ("team:read", "View the name, email domain, and icon for workspaces your slack app is connected to", false),
|
||||
TOKENS_BASIC("tokens.basic", "Execute methods without needing a scope", false),
|
||||
USERGROUPS_READ("usergroups:read", "View user groups in a workspace", false),
|
||||
USERGROUPS_WRITE("usergroups:write", "Create and manage user groups", false),
|
||||
WORKFLOW_STEPS_EXECUTE("workflow.steps:execute", "Add steps that people can use in Workflow Builder", false);
|
||||
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -22,8 +22,8 @@ public enum AuthStackoverflowScope implements AuthScope {
|
||||
WRITE_ACCESS("write_access", "perform write operations as a user", false),
|
||||
PRIVATE_INFO("private_info", "access full history of a user's private actions on the site", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package me.zhyd.oauth.enums.scope;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 企业自建应用授权范围
|
||||
*
|
||||
* @author liguanhua (347826496(a)qq.com)
|
||||
* @since 1.15.9
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AuthWeChatEnterpriseWebScope implements AuthScope {
|
||||
/**
|
||||
* {@code scope} 含义,以{@code description} 为准
|
||||
*/
|
||||
SNSAPI_BASE("snsapi_base", "应用授权作用域。企业自建应用固定填写:snsapi_base", true);
|
||||
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -19,8 +19,8 @@ public enum AuthWechatMpScope implements AuthScope {
|
||||
SNSAPI_USERINFO("snsapi_userinfo", "弹出授权页面,可通过openid拿到昵称、性别、所在地。并且, 即使在未关注的情况下,只要用户授权,也能获取其信息", true),
|
||||
SNSAPI_BASE("snsapi_base", "不弹出授权页面,直接跳转,只能获取用户openid", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ public enum AuthWeiboScope implements AuthScope {
|
||||
STATUSES_TO_ME_READ("statuses_to_me_read", "定向微博读取接口组,<a rel=\"nofollow\" href=\"http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2#.E5.BE.AE.E5.8D.9A\">接口文档</a>", false),
|
||||
FOLLOW_APP_OFFICIAL_MICROBLOG("follow_app_official_microblog", "关注应用官方微博,该参数不对应具体接口,只需在应用控制台填写官方帐号即可。填写的路径:我的应用-选择自己的应用-应用信息-基本信息-官方运营账号(默认值是应用开发者帐号)", false);
|
||||
|
||||
private String scope;
|
||||
private String description;
|
||||
private boolean isDefault;
|
||||
private final String scope;
|
||||
private final String description;
|
||||
private final boolean isDefault;
|
||||
|
||||
}
|
||||
|
||||
@@ -136,15 +136,15 @@ public class Log {
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.10.0
|
||||
*/
|
||||
static class Config {
|
||||
public static class Config {
|
||||
|
||||
/**
|
||||
* 需要打印的日志级别
|
||||
*/
|
||||
static Level level = Level.DEBUG;
|
||||
public static Level level = Level.DEBUG;
|
||||
/**
|
||||
* 是否启用日志打印功能,默认启用
|
||||
*/
|
||||
static boolean enable = true;
|
||||
public static boolean enable = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* 针对JustAuth简单封装的日志打印工具,可用过{@link me.zhyd.oauth.log.Log.Config}开关日志和指定日志级别
|
||||
* 针对JustAuth简单封装的日志打印工具,可用过{@link me.zhyd.oauth.config.JustAuthLogConfig}开关日志和指定日志级别
|
||||
*/
|
||||
package me.zhyd.oauth.log;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class AuthToken implements Serializable {
|
||||
private String accessToken;
|
||||
private int expireIn;
|
||||
private String refreshToken;
|
||||
private int refreshTokenExpireIn;
|
||||
private String uid;
|
||||
private String openId;
|
||||
private String accessCode;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钉钉登录抽象类,负责处理使用钉钉账号登录第三方网站和扫码登录第三方网站两种钉钉的登录方式
|
||||
* </p>
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public abstract class AbstractAuthDingtalkRequest extends AuthDefaultRequest {
|
||||
|
||||
public AbstractAuthDingtalkRequest(AuthConfig config, AuthSource source) {
|
||||
super(config, source);
|
||||
}
|
||||
|
||||
|
||||
public AbstractAuthDingtalkRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {
|
||||
super(config, source, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
return AuthToken.builder().accessCode(authCallback.getCode()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String code = authToken.getAccessCode();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("tmp_auth_code", code);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), param.toJSONString());
|
||||
JSONObject object = JSON.parseObject(response);
|
||||
if (object.getIntValue("errcode") != 0) {
|
||||
throw new AuthException(object.getString("errmsg"));
|
||||
}
|
||||
object = object.getJSONObject("user_info");
|
||||
AuthToken token = AuthToken.builder()
|
||||
.openId(object.getString("openid"))
|
||||
.unionId(object.getString("unionid"))
|
||||
.build();
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("unionid"))
|
||||
.nickname(object.getString("nick"))
|
||||
.username(object.getString("nick"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.source(source.toString())
|
||||
.token(token)
|
||||
.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("response_type", "code")
|
||||
.queryParam("appid", config.getClientId())
|
||||
.queryParam("scope", "snsapi_login")
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
// 根据timestamp, appSecret计算签名值
|
||||
String timestamp = System.currentTimeMillis() + "";
|
||||
String urlEncodeSignature = GlobalAuthUtils.generateDingTalkSignature(config.getClientSecret(), timestamp);
|
||||
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
.queryParam("signature", urlEncodeSignature)
|
||||
.queryParam("timestamp", timestamp)
|
||||
.queryParam("accessKey", config.getClientId())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
+12
-31
@@ -1,41 +1,38 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.config.AuthSource;
|
||||
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.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 企业微信登录
|
||||
* 企业微信登录父类
|
||||
* </p>
|
||||
*
|
||||
* @author yangkai.shen (https://xkcoding.com)
|
||||
* @since 1.10.0
|
||||
* @author liguanhua (347826496(a)qq.com)
|
||||
* @since 1.15.9
|
||||
*/
|
||||
public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
||||
public AuthWeChatEnterpriseRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.WECHAT_ENTERPRISE);
|
||||
public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
||||
|
||||
public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source) {
|
||||
super(config,source);
|
||||
}
|
||||
|
||||
public AuthWeChatEnterpriseRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.WECHAT_ENTERPRISE, authStateCache);
|
||||
|
||||
public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {
|
||||
super(config, source, authStateCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信的特殊性,此时返回的信息同时包含 openid 和 access_token
|
||||
*
|
||||
* @param authCallback 回调返回的参数
|
||||
* @return 所有信息
|
||||
*/
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
String response = doGetAuthorizationCode(accessTokenUrl(authCallback.getCode()));
|
||||
@@ -92,22 +89,6 @@ public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回带{@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("agentid", config.getAgentId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
@@ -43,6 +43,12 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
|
||||
.getAlipayPublicKey(), "RSA2");
|
||||
}
|
||||
|
||||
public AuthAlipayRequest(AuthConfig config, AuthStateCache authStateCache, String proxyHost, Integer proxyPort) {
|
||||
super(config, AuthDefaultSource.ALIPAY, authStateCache);
|
||||
this.alipayClient = new DefaultAlipayClient(AuthDefaultSource.ALIPAY.accessToken(), config.getClientId(), config.getClientSecret(),
|
||||
"json", "UTF-8", config.getAlipayPublicKey(), "RSA2", proxyHost, proxyPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||
|
||||
@@ -8,7 +8,6 @@ import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* 阿里云登录
|
||||
@@ -31,12 +30,12 @@ public class AuthAliyunRequest extends AuthDefaultRequest {
|
||||
String response = doPostAuthorizationCode(authCallback.getCode());
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.idToken(accessTokenObject.getString("id_token"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.build();
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.idToken(accessTokenObject.getString("id_token"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.xkcoding.http.util.UrlUtil;
|
||||
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.enums.scope.AuthAmazonScope;
|
||||
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.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.PkceUtil;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Amazon登录
|
||||
* Login with Amazon for Websites Overview: https://developer.amazon.com/zh/docs/login-with-amazon/register-web.html
|
||||
* Login with Amazon SDK for JavaScript Reference Guide:https://developer.amazon.com/zh/docs/login-with-amazon/javascript-sdk-reference.html
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class AuthAmazonRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthAmazonRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.AMAZON);
|
||||
}
|
||||
|
||||
public AuthAmazonRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.AMAZON, authStateCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://developer.amazon.com/zh/docs/login-with-amazon/authorization-code-grant.html#authorization-request
|
||||
*
|
||||
* @param state state 验证授权流程的参数,可以防止csrf
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
UrlBuilder builder = UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthScopeUtils.getDefaultScopes(AuthAmazonScope.values())))
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("state", getRealState(state));
|
||||
|
||||
if (config.isPkce()) {
|
||||
String cacheKey = this.source.getName().concat(":code_verifier:").concat(config.getClientId());
|
||||
String codeVerifier = PkceUtil.generateCodeVerifier();
|
||||
String codeChallengeMethod = "S256";
|
||||
String codeChallenge = PkceUtil.generateCodeChallenge(codeChallengeMethod, codeVerifier);
|
||||
builder.queryParam("code_challenge", codeChallenge)
|
||||
.queryParam("code_challenge_method", codeChallengeMethod);
|
||||
// 缓存 codeVerifier 十分钟
|
||||
this.authStateCache.cache(cacheKey, codeVerifier, TimeUnit.MINUTES.toMillis(10));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* https://developer.amazon.com/zh/docs/login-with-amazon/authorization-code-grant.html#access-token-request
|
||||
*
|
||||
* @return access token
|
||||
*/
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> form = new HashMap<>(9);
|
||||
form.put("grant_type", "authorization_code");
|
||||
form.put("code", authCallback.getCode());
|
||||
form.put("redirect_uri", config.getRedirectUri());
|
||||
form.put("client_id", config.getClientId());
|
||||
form.put("client_secret", config.getClientSecret());
|
||||
|
||||
if (config.isPkce()) {
|
||||
String cacheKey = this.source.getName().concat(":code_verifier:").concat(config.getClientId());
|
||||
String codeVerifier = this.authStateCache.get(cacheKey);
|
||||
form.put("code_verifier", codeVerifier);
|
||||
}
|
||||
return getToken(form, this.source.accessToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken authToken) {
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("grant_type", "refresh_token");
|
||||
form.put("refresh_token", authToken.getRefreshToken());
|
||||
form.put("client_id", config.getClientId());
|
||||
form.put("client_secret", config.getClientSecret());
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||
.data(getToken(form, this.source.refresh()))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private AuthToken getToken(Map<String, String> param, String url) {
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Host", "api.amazon.com");
|
||||
httpHeader.add(Constants.CONTENT_TYPE, "application/x-www-form-urlencoded;charset=UTF-8");
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(url, param, httpHeader, false);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(jsonObject);
|
||||
return AuthToken.builder()
|
||||
.accessToken(jsonObject.getString("access_token"))
|
||||
.tokenType(jsonObject.getString("token_type"))
|
||||
.expireIn(jsonObject.getIntValue("expires_in"))
|
||||
.refreshToken(jsonObject.getString("refresh_token"))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验响应内容是否正确
|
||||
*
|
||||
* @param jsonObject 响应内容
|
||||
*/
|
||||
private void checkResponse(JSONObject jsonObject) {
|
||||
if (jsonObject.containsKey("error")) {
|
||||
throw new AuthException(jsonObject.getString("error_description").concat(" ") + jsonObject.getString("error_description"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://developer.amazon.com/zh/docs/login-with-amazon/obtain-customer-profile.html#call-profile-endpoint
|
||||
*
|
||||
* @param authToken token信息
|
||||
* @return AuthUser
|
||||
*/
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String accessToken = authToken.getAccessToken();
|
||||
this.checkToken(accessToken);
|
||||
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Host", "api.amazon.com");
|
||||
httpHeader.add("Authorization", "bearer " + accessToken);
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).get(this.source.userInfo(), new HashMap<>(0), httpHeader, false);
|
||||
JSONObject jsonObject = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(jsonObject);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(jsonObject)
|
||||
.uuid(jsonObject.getString("user_id"))
|
||||
.username(jsonObject.getString("name"))
|
||||
.nickname(jsonObject.getString("name"))
|
||||
.email(jsonObject.getString("email"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.source(source.toString())
|
||||
.token(authToken)
|
||||
.build();
|
||||
}
|
||||
|
||||
private void checkToken(String accessToken) {
|
||||
String tokenInfo = new HttpUtils(config.getHttpConfig()).get("https://api.amazon.com/auth/o2/tokeninfo?access_token=" + UrlUtil.urlEncode(accessToken));
|
||||
JSONObject jsonObject = JSONObject.parseObject(tokenInfo);
|
||||
if (!config.getClientId().equals(jsonObject.getString("aud"))) {
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_TOKEN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
.queryParam("user_id", authToken.getUserId())
|
||||
.queryParam("screen_name", authToken.getScreenName())
|
||||
.queryParam("include_entities", true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Cooding登录
|
||||
* Coding登录
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.0.0
|
||||
@@ -85,7 +85,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getCodingGroupName()))
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getDomainPrefix()))
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
@@ -102,7 +102,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getCodingGroupName()))
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getDomainPrefix()))
|
||||
.queryParam("code", code)
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("client_secret", config.getClientSecret())
|
||||
@@ -119,7 +119,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.userInfo(), config.getCodingGroupName()))
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.userInfo(), config.getDomainPrefix()))
|
||||
.queryParam("access_token", authToken.getAccessToken())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
|
||||
/**
|
||||
* 钉钉账号登录
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AuthDingTalkAccountRequest extends AbstractAuthDingtalkRequest {
|
||||
|
||||
public AuthDingTalkAccountRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.DINGTALK_ACCOUNT);
|
||||
}
|
||||
|
||||
public AuthDingTalkAccountRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.DINGTALK_ACCOUNT, authStateCache);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* 钉钉登录
|
||||
* 钉钉二维码登录
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AuthDingTalkRequest extends AuthDefaultRequest {
|
||||
public class AuthDingTalkRequest extends AbstractAuthDingtalkRequest {
|
||||
|
||||
public AuthDingTalkRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.DINGTALK);
|
||||
@@ -29,72 +19,4 @@ public class AuthDingTalkRequest extends AuthDefaultRequest {
|
||||
public AuthDingTalkRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.DINGTALK, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
return AuthToken.builder().accessCode(authCallback.getCode()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String code = authToken.getAccessCode();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("tmp_auth_code", code);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), param.toJSONString());
|
||||
JSONObject object = JSON.parseObject(response);
|
||||
if (object.getIntValue("errcode") != 0) {
|
||||
throw new AuthException(object.getString("errmsg"));
|
||||
}
|
||||
object = object.getJSONObject("user_info");
|
||||
AuthToken token = AuthToken.builder()
|
||||
.openId(object.getString("openid"))
|
||||
.unionId(object.getString("unionid"))
|
||||
.build();
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("unionid"))
|
||||
.nickname(object.getString("nick"))
|
||||
.username(object.getString("nick"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.source(source.toString())
|
||||
.token(token)
|
||||
.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("response_type", "code")
|
||||
.queryParam("appid", config.getClientId())
|
||||
.queryParam("scope", "snsapi_login")
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
// 根据timestamp, appSecret计算签名值
|
||||
String timestamp = System.currentTimeMillis() + "";
|
||||
String urlEncodeSignature = GlobalAuthUtils.generateDingTalkSignature(config.getClientSecret(), timestamp);
|
||||
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
.queryParam("signature", urlEncodeSignature)
|
||||
.queryParam("timestamp", timestamp)
|
||||
.queryParam("accessKey", config.getClientId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
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.enums.scope.AuthDouyinScope;
|
||||
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.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
|
||||
@@ -111,7 +113,7 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_key", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("scope", "user_info")
|
||||
.queryParam("scope", this.getScopes(",", true, AuthScopeUtils.getDefaultScopes(AuthDouyinScope.values())))
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("client_id", config.getClientId());
|
||||
form.put("redirect_uri", config.getRedirectUri());
|
||||
form.put("code", authCallback.getCode());
|
||||
@@ -67,13 +67,13 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
Map<String, Object> parameters = new HashMap<>(4);
|
||||
// 获取商户账号信息的API接口名称
|
||||
String action = "eleme.user.getUser";
|
||||
// 时间戳,单位秒。API服务端允许客户端请求最大时间误差为正负5分钟。
|
||||
final long timestamp = System.currentTimeMillis();
|
||||
// 公共参数
|
||||
Map<String, Object> metasHashMap = new HashMap<>();
|
||||
Map<String, Object> metasHashMap = new HashMap<>(4);
|
||||
metasHashMap.put("app_key", config.getClientId());
|
||||
metasHashMap.put("timestamp", timestamp);
|
||||
String signature = GlobalAuthUtils.generateElemeSignature(config.getClientId(), config.getClientSecret(), timestamp, action, authToken
|
||||
@@ -118,7 +118,7 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken oldToken) {
|
||||
Map<String, String> form = new HashMap<>(2);
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
form.put("refresh_token", oldToken.getRefreshToken());
|
||||
form.put("grant_type", "refresh_token");
|
||||
|
||||
|
||||
@@ -3,9 +3,11 @@ package me.zhyd.oauth.request;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
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;
|
||||
@@ -13,40 +15,63 @@ import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* 注意:该平台暂时存在问题,请不要使用。待修复完成后会重新发版by yadong.zhang
|
||||
* 飞书平台,企业自建应用授权登录,原逻辑由 beacon 集成于 1.14.0 版,但最新的飞书 api 已修改,并且飞书平台一直为 {@code Deprecated} 状态
|
||||
* <p>
|
||||
* 所以,最终修改该平台的实际发布版本为 1.15.9
|
||||
*
|
||||
* @author beacon
|
||||
* @since 1.14.0
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com) 重构业务逻辑 20210101
|
||||
* @since 1.15.9
|
||||
*/
|
||||
@Deprecated
|
||||
public class AuthFeishuRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthFeishuRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.FEISHU);
|
||||
throw new AuthException(AuthResponseStatus.FAILURE);
|
||||
}
|
||||
|
||||
public AuthFeishuRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.FEISHU, authStateCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 app_access_token(企业自建应用)
|
||||
* <p>
|
||||
* Token 有效期为 2 小时,在此期间调用该接口 token 不会改变。当 token 有效期小于 30 分的时候,再次请求获取 token 的时候,
|
||||
* 会生成一个新的 token,与此同时老的 token 依然有效。
|
||||
*
|
||||
* @return appAccessToken
|
||||
*/
|
||||
private String getAppAccessToken() {
|
||||
String cacheKey = this.source.getName().concat(":app_access_token:").concat(config.getClientId());
|
||||
String cacheAppAccessToken = this.authStateCache.get(cacheKey);
|
||||
if (StringUtils.isNotEmpty(cacheAppAccessToken)) {
|
||||
return cacheAppAccessToken;
|
||||
}
|
||||
String url = "https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal/";
|
||||
JSONObject requestObject = new JSONObject();
|
||||
requestObject.put("app_id", config.getClientId());
|
||||
requestObject.put("app_secret", config.getClientSecret());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(url, requestObject.toJSONString(), new HttpHeader()
|
||||
.add("Content-Type", "application/json"));
|
||||
JSONObject jsonObject = JSON.parseObject(response);
|
||||
this.checkResponse(jsonObject);
|
||||
String appAccessToken = jsonObject.getString("app_access_token");
|
||||
// 缓存 app access token
|
||||
this.authStateCache.cache(cacheKey, appAccessToken, jsonObject.getLongValue("expire") * 1000);
|
||||
return appAccessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
JSONObject requestObject = new JSONObject();
|
||||
requestObject.put("app_id", config.getClientId());
|
||||
requestObject.put("app_secret", config.getClientSecret());
|
||||
requestObject.put("app_access_token", this.getAppAccessToken());
|
||||
requestObject.put("grant_type", "authorization_code");
|
||||
requestObject.put("code", authCallback.getCode());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), requestObject.toJSONString(), new HttpHeader()
|
||||
.add("Content-Type", "application/json"));
|
||||
JSONObject jsonObject = JSON.parseObject(response);
|
||||
this.checkResponse(jsonObject);
|
||||
return AuthToken.builder()
|
||||
.accessToken(jsonObject.getString("access_token"))
|
||||
.refreshToken(jsonObject.getString("refresh_token"))
|
||||
.expireIn(jsonObject.getIntValue("expires_in"))
|
||||
.tokenType(jsonObject.getString("token_type"))
|
||||
.openId(jsonObject.getString("open_id"))
|
||||
.build();
|
||||
return getToken(requestObject, this.source.accessToken());
|
||||
|
||||
}
|
||||
|
||||
@@ -57,37 +82,47 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
|
||||
.add("Content-Type", "application/json")
|
||||
.add("Authorization", "Bearer " + accessToken), false);
|
||||
JSONObject object = JSON.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
JSONObject data = object.getJSONObject("data");
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.avatar(object.getString("AvatarUrl"))
|
||||
.username(object.getString("Mobile"))
|
||||
.email(object.getString("Email"))
|
||||
.nickname("Name")
|
||||
.uuid(data.getString("union_id"))
|
||||
.username(data.getString("name"))
|
||||
.nickname(data.getString("name"))
|
||||
.avatar(data.getString("avatar_url"))
|
||||
.email(data.getString("email"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken authToken) {
|
||||
JSONObject requestObject = new JSONObject();
|
||||
requestObject.put("app_id", config.getClientId());
|
||||
requestObject.put("app_secret", config.getClientSecret());
|
||||
requestObject.put("app_access_token", this.getAppAccessToken());
|
||||
requestObject.put("grant_type", "refresh_token");
|
||||
requestObject.put("refresh_token", authToken.getRefreshToken());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), requestObject.toJSONString(), new HttpHeader()
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||
.data(getToken(requestObject, this.source.refresh()))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private AuthToken getToken(JSONObject param, String url) {
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(url, param.toJSONString(), new HttpHeader()
|
||||
.add("Content-Type", "application/json"));
|
||||
JSONObject jsonObject = JSON.parseObject(response);
|
||||
this.checkResponse(jsonObject);
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||
.data(AuthToken.builder()
|
||||
.accessToken(jsonObject.getString("access_token"))
|
||||
.refreshToken(jsonObject.getString("refresh_token"))
|
||||
.expireIn(jsonObject.getIntValue("expires_in"))
|
||||
.tokenType(jsonObject.getString("token_type"))
|
||||
.openId(jsonObject.getString("open_id"))
|
||||
.build())
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
return AuthToken.builder()
|
||||
.accessToken(data.getString("access_token"))
|
||||
.refreshToken(data.getString("refresh_token"))
|
||||
.expireIn(data.getIntValue("expires_in"))
|
||||
.tokenType(data.getString("token_type"))
|
||||
.openId(data.getString("open_id"))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -12,6 +13,7 @@ import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -48,7 +50,9 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String response = doGetUserInfo(authToken);
|
||||
HttpHeader header = new HttpHeader();
|
||||
header.add("Authorization", "token " + authToken.getAccessToken());
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(source.userInfo()).build(), null, header, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object.containsKey("error"), object.getString("error_description"));
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> form = new HashMap<>(5);
|
||||
Map<String, String> form = new HashMap<>(8);
|
||||
form.put("grant_type", "authorization_code");
|
||||
form.put("code", authCallback.getAuthorization_code());
|
||||
form.put("client_id", config.getClientId());
|
||||
@@ -67,7 +67,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("nsp_ts", System.currentTimeMillis() + "");
|
||||
form.put("access_token", authToken.getAccessToken());
|
||||
form.put("nsp_fmt", "JS");
|
||||
@@ -100,7 +100,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken authToken) {
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("client_id", config.getClientId());
|
||||
form.put("client_secret", config.getClientSecret());
|
||||
form.put("refresh_token", authToken.getRefreshToken());
|
||||
|
||||
@@ -41,7 +41,7 @@ public class AuthJdRequest extends AuthDefaultRequest {
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
|
||||
Map<String, String> params = new HashMap<>(5);
|
||||
Map<String, String> params = new HashMap<>(7);
|
||||
params.put("app_key", config.getClientId());
|
||||
params.put("app_secret", config.getClientSecret());
|
||||
params.put("grant_type", "authorization_code");
|
||||
@@ -104,7 +104,7 @@ public class AuthJdRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken oldToken) {
|
||||
Map<String, String> params = new HashMap<>(5);
|
||||
Map<String, String> params = new HashMap<>(7);
|
||||
params.put("app_key", config.getClientId());
|
||||
params.put("app_secret", config.getClientSecret());
|
||||
params.put("grant_type", "refresh_token");
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
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.enums.scope.AuthLineScope;
|
||||
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.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* LINE 登录, line.biz
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class AuthLineRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthLineRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.LINE);
|
||||
}
|
||||
|
||||
public AuthLineRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.LINE, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
return this.getToken(accessTokenUrl(authCallback.getCode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, new HttpHeader()
|
||||
.add("Content-Type", "application/x-www-form-urlencoded")
|
||||
.add("Authorization", "Bearer ".concat(authToken.getAccessToken())), false);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("userId"))
|
||||
.username(object.getString("displayName"))
|
||||
.nickname(object.getString("displayName"))
|
||||
.avatar(object.getString("pictureUrl"))
|
||||
.remark(object.getString("statusMessage"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse revoke(AuthToken authToken) {
|
||||
Map<String, String> params = new HashMap<>(5);
|
||||
params.put("access_token", authToken.getAccessToken());
|
||||
params.put("client_id", config.getClientId());
|
||||
params.put("client_secret", config.getClientSecret());
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).post(source.revoke(), params, false);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
// 返回1表示取消授权成功,否则失败
|
||||
AuthResponseStatus status = object.getBooleanValue("revoked") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;
|
||||
return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken oldToken) {
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||
.data(this.getToken(refreshTokenUrl(oldToken.getRefreshToken())))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token,适用于获取access_token和刷新token
|
||||
*
|
||||
* @param accessTokenUrl 实际请求token的地址
|
||||
* @return token对象
|
||||
*/
|
||||
private AuthToken getToken(String accessTokenUrl) {
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.idToken(accessTokenObject.getString("id_token"))
|
||||
.scope(accessTokenObject.getString("scope"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
.queryParam("user", authToken.getUid())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("nonce", state)
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthScopeUtils.getDefaultScopes(AuthLineScope.values())))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("app_id", config.getClientId());
|
||||
form.put("secret", config.getClientSecret());
|
||||
form.put("code", authCallback.getCode());
|
||||
@@ -55,7 +55,7 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
Map<String, String> form = new HashMap<>(3);
|
||||
Map<String, String> form = new HashMap<>(5);
|
||||
form.put("app_id", config.getClientId());
|
||||
form.put("secret", config.getClientSecret());
|
||||
form.put("access_token", authToken.getAccessToken());
|
||||
@@ -79,7 +79,7 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken oldToken) {
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("app_id", config.getClientId());
|
||||
form.put("secret", config.getClientSecret());
|
||||
form.put("refresh_token", oldToken.getRefreshToken());
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
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.enums.scope.AuthOktaScope;
|
||||
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.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.Base64Utils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Okta 登录
|
||||
* <p>
|
||||
* https://{domainPrefix}.okta.com/oauth2/default/.well-known/oauth-authorization-server
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class AuthOktaRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthOktaRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.OKTA);
|
||||
}
|
||||
|
||||
public AuthOktaRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.OKTA, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
String tokenUrl = accessTokenUrl(authCallback.getCode());
|
||||
return getAuthToken(tokenUrl);
|
||||
}
|
||||
|
||||
private AuthToken getAuthToken(String tokenUrl) {
|
||||
HttpHeader header = new HttpHeader()
|
||||
.add("accept", "application/json")
|
||||
.add("content-type", "application/x-www-form-urlencoded")
|
||||
.add("Authorization", "Basic " + Base64Utils.encode(config.getClientId().concat(":").concat(config.getClientSecret())));
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(tokenUrl, null, header, false);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(accessTokenObject);
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.scope(accessTokenObject.getString("scope"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.idToken(accessTokenObject.getString("id_token"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken authToken) {
|
||||
if (null == authToken.getRefreshToken()) {
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.ILLEGAL_TOKEN.getCode())
|
||||
.msg(AuthResponseStatus.ILLEGAL_TOKEN.getMsg())
|
||||
.build();
|
||||
}
|
||||
String refreshUrl = refreshTokenUrl(authToken.getRefreshToken());
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||
.data(this.getAuthToken(refreshUrl))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpHeader header = new HttpHeader()
|
||||
.add("Authorization", "Bearer " + authToken.getAccessToken());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), null, header, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
JSONObject address = object.getJSONObject("address");
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("sub"))
|
||||
.username(object.getString("name"))
|
||||
.nickname(object.getString("nickname"))
|
||||
.email(object.getString("email"))
|
||||
.location(null == address ? null : address.getString("street_address"))
|
||||
.gender(AuthUserGender.getRealGender(object.getString("sex")))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse revoke(AuthToken authToken) {
|
||||
Map<String, String> params = new HashMap<>(4);
|
||||
params.put("token", authToken.getAccessToken());
|
||||
params.put("token_type_hint", "access_token");
|
||||
|
||||
HttpHeader header = new HttpHeader()
|
||||
.add("Authorization", "Basic " + Base64Utils.encode(config.getClientId().concat(":").concat(config.getClientSecret())));
|
||||
new HttpUtils(config.getHttpConfig()).post(revokeUrl(authToken), params, header, false);
|
||||
AuthResponseStatus status = AuthResponseStatus.SUCCESS;
|
||||
return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();
|
||||
}
|
||||
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.containsKey("error")) {
|
||||
throw new AuthException(object.getString("error_description"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getDomainPrefix(), config.getAuthServerId()))
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("prompt", "consent")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthScopeUtils.getDefaultScopes(AuthOktaScope.values())))
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getDomainPrefix(), config.getAuthServerId()))
|
||||
.queryParam("code", code)
|
||||
.queryParam("grant_type", "authorization_code")
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String refreshTokenUrl(String refreshToken) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.refresh(), config.getDomainPrefix(), config.getAuthServerId()))
|
||||
.queryParam("refresh_token", refreshToken)
|
||||
.queryParam("grant_type", "refresh_token")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String revokeUrl(AuthToken authToken) {
|
||||
return String.format(source.revoke(), config.getDomainPrefix(), config.getAuthServerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfoUrl(AuthToken authToken) {
|
||||
return String.format(source.userInfo(), config.getDomainPrefix(), config.getAuthServerId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
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.enums.scope.AuthSlackScope;
|
||||
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.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* slack登录, slack.com
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class AuthSlackRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthSlackRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.SLACK);
|
||||
}
|
||||
|
||||
public AuthSlackRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.SLACK, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
HttpHeader header = new HttpHeader()
|
||||
.add("Content-Type", "application/x-www-form-urlencoded");
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl(authCallback.getCode()), null, header, false);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(accessTokenObject);
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.scope(accessTokenObject.getString("scope"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.uid(accessTokenObject.getJSONObject("authed_user").getString("id"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpHeader header = new HttpHeader()
|
||||
.add("Content-Type", "application/x-www-form-urlencoded")
|
||||
.add("Authorization", "Bearer ".concat(authToken.getAccessToken()));
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, header, false);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
JSONObject user = object.getJSONObject("user");
|
||||
JSONObject profile = user.getJSONObject("profile");
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(user)
|
||||
.uuid(user.getString("id"))
|
||||
.username(user.getString("name"))
|
||||
.nickname(user.getString("real_name"))
|
||||
.avatar(profile.getString("image_original"))
|
||||
.email(profile.getString("email"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse revoke(AuthToken authToken) {
|
||||
HttpHeader header = new HttpHeader()
|
||||
.add("Content-Type", "application/x-www-form-urlencoded")
|
||||
.add("Authorization", "Bearer ".concat(authToken.getAccessToken()));
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).get(source.revoke(), null, header, false);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
// 返回1表示取消授权成功,否则失败
|
||||
AuthResponseStatus status = object.getBooleanValue("revoked") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;
|
||||
return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查响应内容是否正确
|
||||
*
|
||||
* @param object 请求响应内容
|
||||
*/
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (!object.getBooleanValue("ok")) {
|
||||
String errorMsg = object.getString("error");
|
||||
if (object.containsKey("response_metadata")) {
|
||||
JSONArray array = object.getJSONObject("response_metadata").getJSONArray("messages");
|
||||
if (null != array && array.size() > 0) {
|
||||
errorMsg += "; " + String.join(",", array.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuthException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
.queryParam("user", authToken.getUid())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
||||
*
|
||||
* @param state state 验证授权流程的参数,可以防止csrf
|
||||
* @return 返回授权地址
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("state", getRealState(state))
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("scope", this.getScopes(",", true, AuthScopeUtils.getDefaultScopes(AuthSlackScope.values())))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(source.accessToken())
|
||||
.queryParam("code", code)
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("client_secret", config.getClientSecret())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
Map<String, String> form = new HashMap<>(7);
|
||||
form.put("client_id", config.getClientId());
|
||||
form.put("client_secret", config.getClientSecret());
|
||||
form.put("code", authCallback.getCode());
|
||||
@@ -90,7 +90,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
String uid = oldToken.getUid();
|
||||
String refreshToken = oldToken.getRefreshToken();
|
||||
|
||||
Map<String, String> form = new HashMap<>(2);
|
||||
Map<String, String> form = new HashMap<>(4);
|
||||
form.put("_userId", uid);
|
||||
form.put("refresh_token", refreshToken);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
httpHeader.add("Authorization", header);
|
||||
httpHeader.add(Constants.CONTENT_TYPE, "application/x-www-form-urlencoded");
|
||||
|
||||
Map<String, String> form = new HashMap<>(1);
|
||||
Map<String, String> form = new HashMap<>(3);
|
||||
form.put("oauth_verifier", authCallback.getOauth_verifier());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, httpHeader, false);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
Map<String, String> queryParams = new HashMap<>();
|
||||
Map<String, String> queryParams = new HashMap<>(5);
|
||||
queryParams.put("user_id", authToken.getUserId());
|
||||
queryParams.put("screen_name", authToken.getScreenName());
|
||||
queryParams.put("include_entities", Boolean.toString(true));
|
||||
@@ -162,7 +162,7 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
}
|
||||
|
||||
private Map<String, String> buildOauthParams() {
|
||||
Map<String, String> params = new HashMap<>(5);
|
||||
Map<String, String> params = new HashMap<>(12);
|
||||
params.put("oauth_consumer_key", config.getClientId());
|
||||
params.put("oauth_nonce", GlobalAuthUtils.generateNonce(32));
|
||||
params.put("oauth_signature_method", "HMAC-SHA1");
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 企业微信二维码登录
|
||||
* </p>
|
||||
*
|
||||
* @author yangkai.shen (https://xkcoding.com)
|
||||
* @author liguanhua (347826496(a)qq.com) 重构该类,将通用方法提取
|
||||
* @author lyadong.zhang (yadong.zhang0415(a)gmail.com) 修改类名
|
||||
* @since 1.10.0
|
||||
*/
|
||||
public class AuthWeChatEnterpriseQrcodeRequest extends AbstractAuthWeChatEnterpriseRequest {
|
||||
public AuthWeChatEnterpriseQrcodeRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.WECHAT_ENTERPRISE);
|
||||
}
|
||||
|
||||
public AuthWeChatEnterpriseQrcodeRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.WECHAT_ENTERPRISE, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("appid", config.getClientId())
|
||||
.queryParam("agentid", config.getAgentId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope;
|
||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 企业微信网页登录
|
||||
* </p>
|
||||
*
|
||||
* @author liguanhua (347826496(a)qq.com)
|
||||
* @since 1.15.9
|
||||
*/
|
||||
public class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterpriseRequest {
|
||||
public AuthWeChatEnterpriseWebRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.WECHAT_ENTERPRISE_WEB);
|
||||
}
|
||||
|
||||
public AuthWeChatEnterpriseWebRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.WECHAT_ENTERPRISE_WEB, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("appid", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("scope", this.getScopes(",", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values())))
|
||||
.queryParam("state", getRealState(state).concat("#wechat_redirect"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 喜马拉雅登录
|
||||
*
|
||||
* @author zwzch (zwzch4j@gmail.com)
|
||||
* @since 1.15.9
|
||||
*/
|
||||
public class AuthXmlyRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthXmlyRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.XMLY);
|
||||
}
|
||||
|
||||
public AuthXmlyRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.XMLY, authStateCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取access token
|
||||
*
|
||||
* @param authCallback 授权成功后的回调参数
|
||||
* @return token
|
||||
* @see AuthDefaultRequest#authorize(String)
|
||||
*/
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> map = new HashMap<>(9);
|
||||
map.put("code", authCallback.getCode());
|
||||
map.put("client_id", config.getClientId());
|
||||
map.put("client_secret", config.getClientSecret());
|
||||
map.put("device_id", config.getDeviceId());
|
||||
map.put("grant_type", "authorization_code");
|
||||
map.put("redirect_uri", config.getRedirectUri());
|
||||
String response = HttpUtil.post(source.accessToken(), map, true);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(accessTokenObject);
|
||||
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.uid(accessTokenObject.getString("uid"))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
||||
*
|
||||
* @param state state 验证授权流程的参数,可以防止csrf
|
||||
* @return 返回授权地址
|
||||
* @since 1.15.8
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
.queryParam("client_os_type", "3")
|
||||
.queryParam("device_id", config.getDeviceId())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用token换取用户信息
|
||||
*
|
||||
* @param authToken token信息
|
||||
* @return 用户信息
|
||||
* @see AuthDefaultRequest#getAccessToken(AuthCallback)
|
||||
*/
|
||||
@Override
|
||||
public AuthUser getUserInfo(AuthToken authToken) {
|
||||
Map<String, String> map = new TreeMap<>();
|
||||
map.put("app_key", config.getClientId());
|
||||
map.put("client_os_type", Optional.ofNullable(config.getClientOsType()).orElse(3).toString());
|
||||
map.put("device_id", config.getDeviceId());
|
||||
map.put("pack_id", config.getPackId());
|
||||
map.put("access_token", authToken.getAccessToken());
|
||||
map.put("sig", GlobalAuthUtils.generateXmlySignature(map, config.getClientSecret()));
|
||||
String rawUserInfo = HttpUtil.get(source.userInfo(), map, false);
|
||||
JSONObject object = JSONObject.parseObject(rawUserInfo);
|
||||
checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.uuid(object.getString("id"))
|
||||
.nickname(object.getString("nickname"))
|
||||
.avatar(object.getString("avatar_url"))
|
||||
.rawUserInfo(object)
|
||||
.source(source.toString())
|
||||
.token(authToken)
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验响应结果
|
||||
*
|
||||
* @param object 接口返回的结果
|
||||
*/
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.containsKey("errcode")) {
|
||||
throw new AuthException(object.getIntValue("error_no"), object.getString("error_desc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ public class AuthChecker {
|
||||
* @since 1.6.1-beta
|
||||
*/
|
||||
public static boolean isSupportedAuth(AuthConfig config, AuthSource source) {
|
||||
boolean isSupported = StringUtils.isNotEmpty(config.getClientId()) && StringUtils.isNotEmpty(config.getClientSecret()) && StringUtils.isNotEmpty(config.getRedirectUri());
|
||||
boolean isSupported = StringUtils.isNotEmpty(config.getClientId())
|
||||
&& StringUtils.isNotEmpty(config.getClientSecret());
|
||||
if (isSupported && AuthDefaultSource.ALIPAY == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getAlipayPublicKey());
|
||||
}
|
||||
@@ -35,8 +36,14 @@ public class AuthChecker {
|
||||
if (isSupported && AuthDefaultSource.WECHAT_ENTERPRISE == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getAgentId());
|
||||
}
|
||||
if (isSupported && AuthDefaultSource.CODING == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getCodingGroupName());
|
||||
if (isSupported && (AuthDefaultSource.CODING == source || AuthDefaultSource.OKTA == source)) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getDomainPrefix());
|
||||
}
|
||||
if (isSupported && AuthDefaultSource.XMLY == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getDeviceId()) && null != config.getClientOsType();
|
||||
if (isSupported) {
|
||||
isSupported = config.getClientOsType() == 3 || StringUtils.isNotEmpty(config.getPackId());
|
||||
}
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
@@ -50,6 +57,12 @@ public class AuthChecker {
|
||||
*/
|
||||
public static void checkConfig(AuthConfig config, AuthSource source) {
|
||||
String redirectUri = config.getRedirectUri();
|
||||
if (config.isIgnoreCheckRedirectUri()) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(redirectUri)) {
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);
|
||||
}
|
||||
if (!GlobalAuthUtils.isHttpProtocol(redirectUri) && !GlobalAuthUtils.isHttpsProtocol(redirectUri)) {
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);
|
||||
}
|
||||
|
||||
@@ -101,15 +101,18 @@ public class GlobalAuthUtils {
|
||||
* @return map
|
||||
*/
|
||||
public static Map<String, String> parseStringToMap(String accessTokenStr) {
|
||||
Map<String, String> res = new HashMap<>(6);
|
||||
Map<String, String> res = null;
|
||||
if (accessTokenStr.contains("&")) {
|
||||
String[] fields = accessTokenStr.split("&");
|
||||
res = new HashMap<>((int) (fields.length / 0.75 + 1));
|
||||
for (String field : fields) {
|
||||
if (field.contains("=")) {
|
||||
String[] keyValue = field.split("=");
|
||||
res.put(GlobalAuthUtils.urlDecode(keyValue[0]), keyValue.length == 2 ? GlobalAuthUtils.urlDecode(keyValue[1]) : null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = new HashMap<>(0);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -146,7 +149,7 @@ public class GlobalAuthUtils {
|
||||
if (StringUtils.isEmpty(url)) {
|
||||
return false;
|
||||
}
|
||||
return url.startsWith("http://");
|
||||
return url.startsWith("http://") || url.startsWith("http%3A%2F%2F");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +162,7 @@ public class GlobalAuthUtils {
|
||||
if (StringUtils.isEmpty(url)) {
|
||||
return false;
|
||||
}
|
||||
return url.startsWith("https://");
|
||||
return url.startsWith("https://") || url.startsWith("https%3A%2F%2F");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,6 +223,34 @@ public class GlobalAuthUtils {
|
||||
return new String(Base64Utils.encode(signature, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 喜马拉雅签名算法
|
||||
* {@code https://open.ximalaya.com/doc/detailApi?categoryId=6&articleId=69}
|
||||
*
|
||||
* @param params 加密参数
|
||||
* @param clientSecret 平台应用的授权key
|
||||
* @return Signature
|
||||
* @since 1.15.9
|
||||
*/
|
||||
public static String generateXmlySignature(Map<String, String> params, String clientSecret) {
|
||||
TreeMap<String, String> map = new TreeMap<>(params);
|
||||
String baseStr = Base64Utils.encode(parseMapToString(map, false));
|
||||
byte[] sign = sign(clientSecret.getBytes(DEFAULT_ENCODING), baseStr.getBytes(DEFAULT_ENCODING), HMAC_SHA1);
|
||||
MessageDigest md5 = null;
|
||||
StringBuilder builder = null;
|
||||
try {
|
||||
builder = new StringBuilder();
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(sign);
|
||||
byte[] byteData = md5.digest();
|
||||
for (byte byteDatum : byteData) {
|
||||
builder.append(Integer.toString((byteDatum & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return null == builder ? "" : builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成饿了么请求的Signature
|
||||
* <p>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 该配置仅用于支持 PKCE 模式的平台,针对无服务应用,不推荐使用隐式授权,推荐使用 PKCE 模式
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PkceUtil {
|
||||
|
||||
public static String generateCodeVerifier() {
|
||||
String randomStr = RandomUtil.randomString(50);
|
||||
return Base64Utils.encodeUrlSafe(randomStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 适用于 OAuth 2.0 PKCE 增强协议
|
||||
*
|
||||
* @param codeChallengeMethod s256 / plain
|
||||
* @param codeVerifier 客户端生产的校验码
|
||||
* @return code challenge
|
||||
*/
|
||||
public static String generateCodeChallenge(String codeChallengeMethod, String codeVerifier) {
|
||||
if ("S256".equalsIgnoreCase(codeChallengeMethod)) {
|
||||
// https://tools.ietf.org/html/rfc7636#section-4.2
|
||||
// code_challenge = BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))
|
||||
return newStringUsAscii(Base64Utils.encodeUrlSafe(Sha256.digest(codeVerifier), true));
|
||||
} else {
|
||||
return codeVerifier;
|
||||
}
|
||||
}
|
||||
|
||||
public static String newStringUsAscii(byte[] bytes) {
|
||||
return new String(bytes, StandardCharsets.US_ASCII);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* 生成随机字符串
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class RandomUtil {
|
||||
|
||||
/**
|
||||
* 用于随机选的字符和数字
|
||||
*/
|
||||
public static final String BASE_CHAR_NUMBER = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
/**
|
||||
* 获得一个随机的字符串
|
||||
*
|
||||
* @param length 字符串的长度
|
||||
* @return 指定长度的随机字符串
|
||||
*/
|
||||
public static String randomString(int length) {
|
||||
final StringBuilder sb = new StringBuilder(length);
|
||||
|
||||
if (length < 1) {
|
||||
length = 1;
|
||||
}
|
||||
int baseLength = BASE_CHAR_NUMBER.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = ThreadLocalRandom.current().nextInt(baseLength);
|
||||
sb.append(BASE_CHAR_NUMBER.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* SHA256 加密
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class Sha256 {
|
||||
|
||||
public static byte[] digest(String str) {
|
||||
MessageDigest messageDigest;
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
messageDigest.update(str.getBytes(StandardCharsets.UTF_8));
|
||||
return messageDigest.digest();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user