Skip to content

Commit

Permalink
🔖 增加stackoverflow参数校验、解决Pinterest获取用户失败的问题,发布v1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyd-c committed Jul 20, 2019
1 parent 1244524 commit 798e755
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.9.0-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.9.1-blue.svg" ></img>
</a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
Expand All @@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/">
<img src="https://img.shields.io/badge/Docs-1.9.0-orange.svg" ></img>
<img src="https://img.shields.io/badge/Docs-1.9.1-orange.svg" ></img>
</a>
</p>

Expand Down Expand Up @@ -76,7 +76,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.9.0</version>
<version>1.9.1</version>
</dependency>
```
- 调用api
Expand Down Expand Up @@ -148,7 +148,7 @@ _请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经
2. 把fork过去的项目也就是你仓库中的项目clone到你的本地
3. 修改代码
4. commit后push到自己的库
5. 发起PR(pull request) 请求
5. 发起PR(pull request) 请求,提交到`dev`分支
6. 等待作者合并

## 致谢
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.9.0</version>
<version>1.9.1</version>

<name>JustAuth</name>
<url>https://gitee.com/yadong.zhang/JustAuth</url>
Expand Down Expand Up @@ -190,4 +190,4 @@
</distributionManagement>
</profile>
</profiles>
</project>
</project>
4 changes: 4 additions & 0 deletions src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public String authorize() {
/**
* 返回获取accessToken的url
*
* @param code 授权码
* @return 返回获取accessToken的url
*/
protected String accessTokenUrl(String code) {
Expand All @@ -95,6 +96,7 @@ protected String accessTokenUrl(String code) {
/**
* 返回获取accessToken的url
*
* @param refreshToken refreshToken
* @return 返回获取accessToken的url
*/
protected String refreshTokenUrl(String refreshToken) {
Expand All @@ -110,6 +112,7 @@ protected String refreshTokenUrl(String refreshToken) {
/**
* 返回获取userInfo的url
*
* @param authToken token
* @return 返回获取userInfo的url
*/
protected String userInfoUrl(AuthToken authToken) {
Expand All @@ -119,6 +122,7 @@ protected String userInfoUrl(AuthToken authToken) {
/**
* 返回获取revoke authorization的url
*
* @param authToken token
* @return 返回获取revoke authorization的url
*/
protected String revokeUrl(AuthToken authToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String authorize() {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String authorize() {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public String authorize() {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public String authorize() {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected String accessTokenUrl(String code) {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand All @@ -150,7 +150,7 @@ protected String userInfoUrl(AuthToken authToken) {
/**
* 返回获取accessToken的url
*
* @param refreshToken
* @param refreshToken 用户授权后的token
* @return 返回获取accessToken的url
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected String accessTokenUrl(String code) {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ protected AuthToken getAccessToken(AuthCallback authCallback) {

@Override
protected AuthUser getUserInfo(AuthToken authToken) {
String userinfoUrl = UrlBuilder.fromBaseUrl(userInfoUrl(authToken))
.queryParam("fields", "id,username,first_name,last_name,bio,image")
.build();
HttpResponse response = HttpRequest.post(userinfoUrl).execute();
String userinfoUrl = userInfoUrl(authToken);
HttpResponse response = HttpRequest.get(userinfoUrl).setFollowRedirects(true).execute();
JSONObject object = JSONObject.parseObject(response.body());
this.checkResponse(object);
JSONObject userObj = object.getJSONObject("data");
Expand Down Expand Up @@ -82,6 +80,19 @@ public String authorize() {
.build();
}

/**
* 返回获取userInfo的url
*
* @param authToken token
* @return 返回获取userInfo的url
*/
protected String userInfoUrl(AuthToken authToken) {
return UrlBuilder.fromBaseUrl(source.userInfo())
.queryParam("access_token", authToken.getAccessToken())
.queryParam("fields", "id,username,first_name,last_name,bio,image")
.build();
}

/**
* 检查响应内容是否正确
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private String getCompany(JSONObject userObj) {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected AuthUser getUserInfo(AuthToken authToken) {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken authToken
* @return 返回获取userInfo的url
*/
@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/me/zhyd/oauth/utils/AuthChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static boolean isSupportedAuth(AuthConfig config, AuthSource source) {
if (isSupported && AuthSource.ALIPAY == source) {
isSupported = StringUtils.isNotEmpty(config.getAlipayPublicKey());
}
if (isSupported && AuthSource.STACK_OVERFLOW == source) {
isSupported = StringUtils.isNotEmpty(config.getStackOverflowKey());
}
return isSupported;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/zhyd/oauth/utils/GlobalAuthUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static byte[] sign(byte[] key, byte[] data) {
}
}

private static String urlEncode(String value) {
public static String urlEncode(String value) {
if (value == null) {
return "";
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* </p>
*
* @author yangkai.shen (https://xkcoding.com)
* @date Created in 2019-07-18 15:47
* @version 1.0
* @since 1.8
*/
Expand Down
6 changes: 6 additions & 0 deletions update.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### 2019/07/19

1. 增加`stackoverflow`参数校验
2. 解决`Pinterest`获取用户失败的问题
3. 添加注释

### 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`枚举类
Expand Down

0 comments on commit 798e755

Please sign in to comment.