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

Merge remote-tracking branch 'origin/master'

...@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl ...@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username otechie: # Replace with a single Otechie username
custom: ['https://justauth.wiki/sponsor.html'] custom: ['https://www.justauth.cn/sponsor.html']
...@@ -9,8 +9,8 @@ assignees: '' ...@@ -9,8 +9,8 @@ assignees: ''
## Pre-submission checklist: ## Pre-submission checklist:
- [ ] I have searched the relevant information in the existing list of Issues. - [ ] 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 searched the developer documentation for that information: https://www.justauth.cn
- [ ] I have read the relevant Q&A: https://justauth.wiki - [ ] I have read the relevant Q&A: https://www.justauth.cn
## Issue description ## Issue description
......
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
- 新增 [微信企业版登录](oauth/wechatEnterprise.md)文档 - 新增 [微信企业版登录](oauth/wechatEnterprise.md)文档
- 新增 [Facebook 登录](oauth/facebook.md)文档 - 新增 [Facebook 登录](oauth/facebook.md)文档
- 完善 [JustAuth 使用者](users.md)文档 - 完善 [JustAuth 使用者](users.md)文档
- 替换“帮助文档”域名,由[https://docs.justauth.whnb.wang](https://docs.justauth.whnb.wang)迁移到[https://justauth.wiki](https://justauth.wiki) - 替换“帮助文档”域名,由[https://docs.justauth.whnb.wang](https://docs.justauth.whnb.wang)迁移到[https://www.justauth.cn](https://www.justauth.cn)
- 新增 - 新增
- 增加阿里云授权登录中刷新授权token的接口,by “QQ群用户需求” - 增加阿里云授权登录中刷新授权token的接口,by “QQ群用户需求”
- AuthConfig 增加忽略校验 state 的参数,详情参考:[Github#Issue#83](https://github.com/justauth/JustAuth/issues/83) - AuthConfig 增加忽略校验 state 的参数,详情参考:[Github#Issue#83](https://github.com/justauth/JustAuth/issues/83)
...@@ -214,7 +214,7 @@ new AuthGoogleRequest(AuthConfig.builder() ...@@ -214,7 +214,7 @@ new AuthGoogleRequest(AuthConfig.builder()
- 修复 - 修复
- 解决 Twitter 授权失败的BUG - 解决 Twitter 授权失败的BUG
- 文档 - 文档
- 完善 [https://justauth.wiki](https://justauth.wiki/) 的404引导页内容 - 完善 [https://www.justauth.cn](https://www.justauth.cn/) 的404引导页内容
- 增加名词解释: `uuid` - 增加名词解释: `uuid`
- 补充 [Q&A](Q&A.md) - 补充 [Q&A](Q&A.md)
- 新增 [参考文档](references.md),包含 OAuth 授权和第三方平台的API文档等内容 - 新增 [参考文档](references.md),包含 OAuth 授权和第三方平台的API文档等内容
...@@ -294,9 +294,9 @@ System.setProperty("proxyHost", "127.0.0.1"); ...@@ -294,9 +294,9 @@ System.setProperty("proxyHost", "127.0.0.1");
- 新增 - 新增
- 增加微信、QQ、支付宝、微博授权登录的帮助文档 - 增加微信、QQ、支付宝、微博授权登录的帮助文档
- 合并[PR#57](https://github.com/justauth/JustAuth/pull/57),增加微信公众号登录 by [@xkcoding](https://github.com/xkcoding) - 合并[PR#57](https://github.com/justauth/JustAuth/pull/57),增加微信公众号登录 by [@xkcoding](https://github.com/xkcoding)
- [帮助文档](https://justauth.wiki)中增加自定义的404页面 - [帮助文档](https://www.justauth.cn)中增加自定义的404页面
- [帮助文档](https://justauth.wiki)中增加Gittalk插件 - [帮助文档](https://www.justauth.cn)中增加Gittalk插件
- [帮助文档](https://justauth.wiki)中增加Java代码高亮的插件 - [帮助文档](https://www.justauth.cn)中增加Java代码高亮的插件
- 增加`AuthUserGender#getWechatRealGender`方法,兼容获取微信平台的用户性别 - 增加`AuthUserGender#getWechatRealGender`方法,兼容获取微信平台的用户性别
- 修改 - 修改
- 修复抖音登录取值取错层级的问题([issue#I15SIG@Gitee](https://gitee.com/yadong.zhang/JustAuth/issues/I15SIG) - 修复抖音登录取值取错层级的问题([issue#I15SIG@Gitee](https://gitee.com/yadong.zhang/JustAuth/issues/I15SIG)
...@@ -305,7 +305,7 @@ System.setProperty("proxyHost", "127.0.0.1"); ...@@ -305,7 +305,7 @@ System.setProperty("proxyHost", "127.0.0.1");
- `AuthResponseStatus`枚举类中增加`ILLEGAL_STATUS``REQUIRED_REFRESH_TOKEN`两个枚举值 - `AuthResponseStatus`枚举类中增加`ILLEGAL_STATUS``REQUIRED_REFRESH_TOKEN`两个枚举值
- `AuthSource`接口中增加`getName`方法,用来对外提供实际`source`的字符串值 - `AuthSource`接口中增加`getName`方法,用来对外提供实际`source`的字符串值
- `AuthWeiboRequest`微博授权登录中实现`revoke`方法,支持手动回收授权 - `AuthWeiboRequest`微博授权登录中实现`revoke`方法,支持手动回收授权
- [帮助文档](https://justauth.wiki)中修复[腾讯云登录]链接错误的问题 - [帮助文档](https://www.justauth.cn)中修复[腾讯云登录]链接错误的问题
- 升级 - 升级
- 升级相关依赖: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) - 升级相关依赖: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)
......
<p align="center"> <p align="center">
<a href="https://justauth.wiki"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/Justauth.png" width="400"></a> <a href="https://www.justauth.cn"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/Justauth.png" width="400"></a>
</p> </p>
<p align="center"> <p align="center">
<strong>Login, so easy.</strong> <strong>Login, so easy.</strong>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html"> <a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a> </a>
<a target="_blank" href="https://justauth.wiki" title="参考文档"> <a target="_blank" href="https://www.justauth.cn" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img> <img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
</a> </a>
<a href="https://codecov.io/gh/justauth/JustAuth"> <a href="https://codecov.io/gh/justauth/JustAuth">
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
`JustAuth`, as you see, It is just a Java library of third-party authorized login, It's smaller and easier to use. JustAuth is the best third-party login tool written in JAVA. `JustAuth`, as you see, It is just a Java library of third-party authorized login, It's smaller and easier to use. JustAuth is the best third-party login tool written in JAVA.
Source Code:[gitee](https://gitee.com/yadong.zhang/JustAuth) | [github](https://github.com/zhangyd-c/JustAuth) Source Code:[gitee](https://gitee.com/yadong.zhang/JustAuth) | [github](https://github.com/zhangyd-c/JustAuth)
Docs:[Reference Doc](https://justauth.wiki) Docs:[Reference Doc](https://www.justauth.cn)
## Features ## Features
...@@ -180,11 +180,11 @@ I look forward to your joining us. ...@@ -180,11 +180,11 @@ I look forward to your joining us.
## Contributors ## Contributors
[contributors](https://justauth.wiki/contributors.html) [contributors](https://www.justauth.cn/contributors.html)
## Change Logs ## Change Logs
[CHANGELOGS](https://justauth.wiki/update.html) [CHANGELOGS](https://www.justauth.cn/update.html)
## Recommend ## Recommend
......
<p align="center"> <p align="center">
<a href="https://justauth.wiki"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/Justauth.png" width="400"></a> <a href="https://www.justauth.cn"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/Justauth.png" width="400"></a>
</p> </p>
<p align="center"> <p align="center">
<strong>Login, so easy.</strong> <strong>Login, so easy.</strong>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html"> <a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a> </a>
<a target="_blank" href="https://justauth.wiki" title="参考文档"> <a target="_blank" href="https://www.justauth.cn" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img> <img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
</a> </a>
<a href="https://codecov.io/gh/justauth/JustAuth"> <a href="https://codecov.io/gh/justauth/JustAuth">
...@@ -40,13 +40,13 @@ ...@@ -40,13 +40,13 @@
QQ 群:230017570 QQ 群:230017570
微信群:justauth (备注`justauth`或者`ja` 微信群:justauth (备注`justauth`或者`ja`
帮助文档:[justauth.wiki](https://justauth.wiki) 帮助文档:[www.justauth.cn](https://www.justauth.cn)
## 什么是 JustAuth? ## 什么是 JustAuth?
JustAuth,如你所见,它仅仅是一个**第三方授权登录****工具类库**,它可以让我们脱离繁琐的第三方登录 SDK,让登录变得**So easy!** JustAuth,如你所见,它仅仅是一个**第三方授权登录****工具类库**,它可以让我们脱离繁琐的第三方登录 SDK,让登录变得**So easy!**
JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、Google、Facebook、Twitter、StackOverflow等国内外数十家第三方平台。更多请参考<a href="https://justauth.wiki" target="_blank">已集成的平台</a> JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、Google、Facebook、Twitter、StackOverflow等国内外数十家第三方平台。更多请参考<a href="https://www.justauth.cn" target="_blank">已集成的平台</a>
## 有哪些特点? ## 有哪些特点?
...@@ -55,12 +55,12 @@ JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、 ...@@ -55,12 +55,12 @@ JustAuth 集成了诸如:Github、Gitee、支付宝、新浪微博、微信、
## 有哪些功能? ## 有哪些功能?
- 集成国内外数十家第三方平台,实现快速接入。<a href="https://justauth.wiki/quickstart/how-to-use.html" target="_blank">参考文档</a> - 集成国内外数十家第三方平台,实现快速接入。<a href="https://www.justauth.cn/quickstart/how-to-use.html" target="_blank">参考文档</a>
- 自定义 State 缓存,支持各种分布式缓存组件。<a href="https://justauth.wiki/features/customize-the-state-cache.html" target="_blank">参考文档</a> - 自定义 State 缓存,支持各种分布式缓存组件。<a href="https://www.justauth.cn/features/customize-the-state-cache.html" target="_blank">参考文档</a>
- 自定义 OAuth 平台,更容易适配自有的 OAuth 服务。<a href="https://justauth.wiki/features/customize-the-oauth.html" target="_blank">参考文档</a> - 自定义 OAuth 平台,更容易适配自有的 OAuth 服务。<a href="https://www.justauth.cn/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> - 自定义 Http 实现,选择权完全交给开发者,不会单独依赖某一具体实现。<a href="https://www.justauth.cn/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> - 自定义 Scope,支持更完善的授权体系。<a href="https://www.justauth.cn/features/customize-scopes.html" target="_blank">参考文档</a>
- 更多...<a href="https://justauth.wiki" target="_blank">参考文档</a> - 更多...<a href="https://www.justauth.cn" target="_blank">参考文档</a>
## 快速开始 ## 快速开始
...@@ -214,7 +214,7 @@ AuthRequest authRequest = AuthRequestBuilder.builder() ...@@ -214,7 +214,7 @@ AuthRequest authRequest = AuthRequestBuilder.builder()
感谢以下赞助商的支持: 感谢以下赞助商的支持:
[我要赞助](https://justauth.wiki/sponsor.html) [我要赞助](https://www.justauth.cn/sponsor.html)
## JustAuth 的用户 ## JustAuth 的用户
有很多公司、组织和个人把 JustAuth 用于学习、研究、生产环境和商业产品中,包括(但不限于): 有很多公司、组织和个人把 JustAuth 用于学习、研究、生产环境和商业产品中,包括(但不限于):
...@@ -234,7 +234,7 @@ AuthRequest authRequest = AuthRequestBuilder.builder() ...@@ -234,7 +234,7 @@ AuthRequest authRequest = AuthRequestBuilder.builder()
- `mica` SpringBoot 微服务高效开发工具集: [https://github.com/lets-mica/mica](https://github.com/lets-mica/mica) - `mica` SpringBoot 微服务高效开发工具集: [https://github.com/lets-mica/mica](https://github.com/lets-mica/mica)
- `sureness` 面向restful api的高性能认证鉴权框架:[sureness](https://github.com/usthe/sureness) - `sureness` 面向restful api的高性能认证鉴权框架:[sureness](https://github.com/usthe/sureness)
更多推荐,请参考:[JustAuth - 开源推荐](https://justauth.wiki) 更多推荐,请参考:[JustAuth - 开源推荐](https://www.justauth.cn)
## 鸣谢 ## 鸣谢
...@@ -246,8 +246,8 @@ AuthRequest authRequest = AuthRequestBuilder.builder() ...@@ -246,8 +246,8 @@ AuthRequest authRequest = AuthRequestBuilder.builder()
## 其他 ## 其他
- [CONTRIBUTORS](https://justauth.wiki/contributors.html) - [CONTRIBUTORS](https://www.justauth.cn/contributors.html)
- [CHANGELOGS](https://justauth.wiki/update.html) - [CHANGELOGS](https://www.justauth.cn/update.html)
- [PLAN](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK) - [PLAN](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK)
## 贡献者列表 ## 贡献者列表
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</head> </head>
<body> <body>
<script> <script>
window.location.href = "https://justauth.wiki"; window.location.href = "https://www.justauth.cn";
</script> </script>
</body> </body>
</html> </html>
...@@ -96,6 +96,10 @@ _注:非全部平台,部分平台可能不存在图例_ ...@@ -96,6 +96,10 @@ _注:非全部平台,部分平台可能不存在图例_
![授权Stack Overflow](https://images.gitee.com/uploads/images/2019/0718/192639_cc301ba7_784199.png "授权Stack Overflow") ![授权Stack Overflow](https://images.gitee.com/uploads/images/2019/0718/192639_cc301ba7_784199.png "授权Stack Overflow")
#### 授权afdian
![授权afdian](https://img.fastmirror.net/s/2023/03/24/641d63a8c19b5.png "授权afDian")
#### 授权Twitter #### 授权Twitter
![授权Twitter]( "授权Twitter") ![授权Twitter]( "授权Twitter")
......
...@@ -1268,6 +1268,30 @@ public enum AuthDefaultSource implements AuthSource { ...@@ -1268,6 +1268,30 @@ public enum AuthDefaultSource implements AuthSource {
return "https://www.proginn.com/openapi/user/basic_info"; return "https://www.proginn.com/openapi/user/basic_info";
} }
@Override
public Class<? extends AuthDefaultRequest> getTargetClass() {
return AuthProginnRequest.class;
}
},
/**
* 爱发电 <a href="https://afdian.net/">爱发电</a>
*/
AFDIAN {
@Override
public String authorize() {
return "https://afdian.net/oauth2/authorize";
}
@Override
public String accessToken() {
return "https://afdian.net/api/oauth2/access_token";
}
@Override
public String userInfo() {
return "";
}
@Override @Override
public Class<? extends AuthDefaultRequest> getTargetClass() { public Class<? extends AuthDefaultRequest> getTargetClass() {
return AuthProginnRequest.class; return AuthProginnRequest.class;
......
package me.zhyd.oauth.request;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthDefaultSource;
import me.zhyd.oauth.enums.AuthUserGender;
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;
import java.util.HashMap;
import java.util.Map;
/**
* 爱发电
*
* @author handy
*/
public class AuthAfDianRequest extends AuthDefaultRequest {
public AuthAfDianRequest(AuthConfig config) {
super(config, AuthDefaultSource.AFDIAN);
}
public AuthAfDianRequest(AuthConfig config, AuthStateCache authStateCache) {
super(config, AuthDefaultSource.AFDIAN, authStateCache);
}
@Override
protected AuthToken getAccessToken(AuthCallback authCallback) {
Map<String, String> params = new HashMap<>();
params.put("grant_type", "authorization_code");
params.put("client_id", config.getClientId());
params.put("client_secret", config.getClientSecret());
params.put("code", authCallback.getCode());
params.put("redirect_uri", config.getRedirectUri());
String response = new HttpUtils(config.getHttpConfig()).post(AuthDefaultSource.AFDIAN.accessToken(), params, false).getBody();
JSONObject accessTokenObject = JSONObject.parseObject(response);
String userId = accessTokenObject.getJSONObject("data").getString("user_id");
return AuthToken.builder().userId(userId).build();
}
@Override
protected AuthUser getUserInfo(AuthToken authToken) {
return AuthUser.builder()
.uuid(authToken.getUserId())
.gender(AuthUserGender.UNKNOWN)
.token(authToken)
.source(source.toString())
.build();
}
/**
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
*
* @param state state 验证授权流程的参数,可以防止csrf
* @return 返回授权地址
*/
@Override
public String authorize(String state) {
return UrlBuilder.fromBaseUrl(source.authorize())
.queryParam("response_type", "code")
.queryParam("scope", "basic")
.queryParam("client_id", config.getClientId())
.queryParam("redirect_uri", config.getRedirectUri())
.queryParam("state", getRealState(state))
.build();
}
}
...@@ -32,7 +32,6 @@ public class AuthFeiShuRequestTest { ...@@ -32,7 +32,6 @@ public class AuthFeiShuRequestTest {
System.out.println("state==" + state); System.out.println("state==" + state);
String authorize = request.authorize(state); String authorize = request.authorize(state);
System.out.println("authorize==" + authorize); System.out.println("authorize==" + authorize);
Assert.assertNotNull(authorize);
} }
@Test @Test
...@@ -50,11 +49,9 @@ public class AuthFeiShuRequestTest { ...@@ -50,11 +49,9 @@ public class AuthFeiShuRequestTest {
.state(state) .state(state)
.build(); .build();
AuthToken accessToken = ((AuthFeishuRequest) request).getAccessToken(callback); AuthToken accessToken = ((AuthFeishuRequest) request).getAccessToken(callback);
Assert.assertNotNull(accessToken);
System.out.println("token==" + accessToken.getAccessToken()); System.out.println("token==" + accessToken.getAccessToken());
AuthUser userInfo = ((AuthFeishuRequest) request).getUserInfo(accessToken); AuthUser userInfo = ((AuthFeishuRequest) request).getUserInfo(accessToken);
Assert.assertNotNull(userInfo);
System.out.println("userInfo==" + JSON.toJSONString(userInfo)); System.out.println("userInfo==" + JSON.toJSONString(userInfo));
} }
...@@ -74,9 +71,7 @@ public class AuthFeiShuRequestTest { ...@@ -74,9 +71,7 @@ public class AuthFeiShuRequestTest {
.state(state) .state(state)
.build(); .build();
AuthResponse response = request.login(callback); AuthResponse response = request.login(callback);
Assert.assertNotNull(response);
AuthUser user = (AuthUser) response.getData(); AuthUser user = (AuthUser) response.getData();
Assert.assertNotNull(user);
System.out.println(JSON.toJSONString(user)); System.out.println(JSON.toJSONString(user));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册