Merge branch 'master' into dev
This commit is contained in:
@@ -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.8.1-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>
|
||||
@@ -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.8.1-orange.svg" ></img>
|
||||
<img src="https://img.shields.io/badge/Docs-1.9.1-orange.svg" ></img>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -76,7 +76,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.9.1</version>
|
||||
</dependency>
|
||||
```
|
||||
- 调用api
|
||||
@@ -148,7 +148,7 @@ _请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经
|
||||
2. 把fork过去的项目也就是你仓库中的项目clone到你的本地
|
||||
3. 修改代码
|
||||
4. commit后push到自己的库
|
||||
5. 发起PR(pull request) 请求
|
||||
5. 发起PR(pull request) 请求,提交到`dev`分支
|
||||
6. 等待作者合并
|
||||
|
||||
## 致谢
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -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>
|
||||
@@ -57,7 +57,7 @@
|
||||
<hutool-version>4.5.15</hutool-version>
|
||||
<lombok-version>1.18.4</lombok-version>
|
||||
<junit-version>4.11</junit-version>
|
||||
<fastjson-version>1.2.44</fastjson-version>
|
||||
<fastjson-version>1.2.58</fastjson-version>
|
||||
<alipay-sdk-version>3.7.4.ALL</alipay-sdk-version>
|
||||
<slf4j-version>1.7.25</slf4j-version>
|
||||
</properties>
|
||||
@@ -190,4 +190,4 @@
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -294,7 +294,7 @@ public enum AuthSource {
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://oauth2.googleapis.com/tokeninfo";
|
||||
return "https://www.googleapis.com/oauth2/v3/userinfo";
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -81,7 +81,7 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
|
||||
.location(location)
|
||||
.gender(AuthUserGender.getRealGender(response.getGender()))
|
||||
.token(authToken)
|
||||
.source(AuthSource.ALIPAY)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import me.zhyd.oauth.config.AuthSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.*;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
@@ -39,14 +40,19 @@ public class AuthBaiduRequest extends AuthDefaultRequest {
|
||||
.uuid(object.getString("userid"))
|
||||
.username(object.getString("username"))
|
||||
.nickname(object.getString("username"))
|
||||
.avatar(object.getString("portrait"))
|
||||
.avatar(getAvatar(object))
|
||||
.remark(object.getString("userdetail"))
|
||||
.gender(AuthUserGender.getRealGender(object.getString("sex")))
|
||||
.token(authToken)
|
||||
.source(AuthSource.BAIDU)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
private String getAvatar(JSONObject object) {
|
||||
String protrait = object.getString("portrait");
|
||||
return StringUtils.isEmpty(protrait) ? null : String.format("http://himg.bdimg.com/sys/portrait/item/%s.jpg", protrait);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse revoke(AuthToken authToken) {
|
||||
HttpResponse response = doGetRevoke(authToken);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
.email(object.getString("email"))
|
||||
.remark(object.getString("slogan"))
|
||||
.token(authToken)
|
||||
.source(AuthSource.CODING)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AuthCsdnRequest extends AuthDefaultRequest {
|
||||
.blog(object.getString("website"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.CSDN)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import me.zhyd.oauth.utils.UrlBuilder;
|
||||
* @version 1.0
|
||||
* @since 1.8
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
protected AuthConfig config;
|
||||
@@ -81,6 +80,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
*
|
||||
* @param code 授权码
|
||||
* @return 返回获取accessToken的url
|
||||
*/
|
||||
protected String accessTokenUrl(String code) {
|
||||
@@ -96,6 +96,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
*
|
||||
* @param refreshToken refreshToken
|
||||
* @return 返回获取accessToken的url
|
||||
*/
|
||||
protected String refreshTokenUrl(String refreshToken) {
|
||||
@@ -111,6 +112,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
@@ -120,6 +122,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
/**
|
||||
* 返回获取revoke authorization的url
|
||||
*
|
||||
* @param authToken token
|
||||
* @return 返回获取revoke authorization的url
|
||||
*/
|
||||
protected String revokeUrl(AuthToken authToken) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class AuthDingTalkRequest extends AuthDefaultRequest {
|
||||
.nickname(object.getString("nick"))
|
||||
.username(object.getString("nick"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.source(AuthSource.DINGTALK)
|
||||
.source(source)
|
||||
.token(token)
|
||||
.build();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class AuthDingTalkRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
|
||||
.remark(userInfoObject.getString("description"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.DOUYIN)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AuthFacebookRequest extends AuthDefaultRequest {
|
||||
.email(object.getString("email"))
|
||||
.gender(AuthUserGender.getRealGender(object.getString("gender")))
|
||||
.token(authToken)
|
||||
.source(AuthSource.FACEBOOK)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AuthGiteeRequest extends AuthDefaultRequest {
|
||||
.remark(object.getString("bio"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.GITEE)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ 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.GlobalAuthUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Github登录
|
||||
@@ -26,12 +29,14 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
HttpResponse response = doPostAuthorizationCode(authCallback.getCode());
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
|
||||
this.checkResponse(accessTokenObject);
|
||||
Map<String, String> res = GlobalAuthUtil.parseStringToMap(response.body());
|
||||
if (res.containsKey("error")) {
|
||||
throw new AuthException(res.get("error") + ":" + res.get("error_description"));
|
||||
}
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.scope(accessTokenObject.getString("scope"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.accessToken(res.get("access_token"))
|
||||
.scope(res.get("scope"))
|
||||
.tokenType(res.get("token_type"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -39,7 +44,9 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpResponse response = doGetUserInfo(authToken);
|
||||
JSONObject object = JSONObject.parseObject(response.body());
|
||||
this.checkResponse(object);
|
||||
if (object.containsKey("error")) {
|
||||
throw new AuthException(object.getString("error_description"));
|
||||
}
|
||||
return AuthUser.builder()
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("login"))
|
||||
@@ -52,7 +59,7 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
.remark(object.getString("bio"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.GITHUB)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -62,8 +69,6 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
* @param object 请求响应内容
|
||||
*/
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.containsKey("error")) {
|
||||
throw new AuthException(object.getString("error_description"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@@ -40,25 +41,28 @@ public class AuthGoogleRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpResponse response = doGetUserInfo(authToken);
|
||||
HttpResponse response = HttpRequest.post(userInfoUrl(authToken))
|
||||
.header("Authorization", "Bearer " + authToken.getAccessToken())
|
||||
.execute();
|
||||
String userInfo = response.body();
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.uuid(object.getString("sub"))
|
||||
.username(object.getString("name"))
|
||||
.username(object.getString("email"))
|
||||
.avatar(object.getString("picture"))
|
||||
.nickname(object.getString("name"))
|
||||
.location(object.getString("locale"))
|
||||
.email(object.getString("email"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.GOOGLE)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回认证url,可自行跳转页面
|
||||
* https://openidconnect.googleapis.com/v1/userinfo
|
||||
*
|
||||
* @return 返回授权地址
|
||||
*/
|
||||
@@ -76,12 +80,12 @@ public class AuthGoogleRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo()).queryParam("id_token", authToken.getAccessToken()).build();
|
||||
return UrlBuilder.fromBaseUrl(source.userInfo()).queryParam("access_token", authToken.getAccessToken()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +95,7 @@ public class AuthGoogleRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.containsKey("error") || object.containsKey("error_description")) {
|
||||
throw new AuthException(object.getString("error_description"));
|
||||
throw new AuthException(object.containsKey("error") + ":" + object.getString("error_description"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
@@ -120,13 +121,8 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
.execute();
|
||||
JSONObject emailObj = JSONObject.parseObject(emailResponse.body());
|
||||
this.checkResponse(emailObj);
|
||||
if (emailObj.containsKey("elements")) {
|
||||
email = emailObj.getJSONArray("elements")
|
||||
.getJSONObject(0)
|
||||
.getJSONObject("handle~")
|
||||
.getString("emailAddress");
|
||||
}
|
||||
return email;
|
||||
Object obj = JSONPath.eval(emailObj, "$['elements'][0]['handle~']['emailAddress']");
|
||||
return null == obj ? null : (String) obj;
|
||||
}
|
||||
|
||||
private String getUserName(JSONObject userInfoObject, String nameKey) {
|
||||
@@ -204,7 +200,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class AuthMiRequest extends AuthDefaultRequest {
|
||||
.email(user.getString("mail"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.MI)
|
||||
.source(source)
|
||||
.build();
|
||||
|
||||
// 获取用户邮箱手机号等信息
|
||||
@@ -128,7 +128,7 @@ public class AuthMiRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -83,7 +83,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
.email(object.getString("mail"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.MICROSOFT)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
@@ -150,7 +150,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
*
|
||||
* @param refreshToken
|
||||
* @param refreshToken 用户授权后的token
|
||||
* @return 返回获取accessToken的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class AuthOschinaRequest extends AuthDefaultRequest {
|
||||
.gender(AuthUserGender.getRealGender(object.getString("gender")))
|
||||
.email(object.getString("email"))
|
||||
.token(authToken)
|
||||
.source(AuthSource.OSCHINA)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class AuthOschinaRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import static me.zhyd.oauth.config.AuthSource.PINTEREST;
|
||||
*
|
||||
* @author hongwei.peng (pengisgood(at)gmail(dot)com)
|
||||
* @version 1.9.0
|
||||
* @since 1.9.0
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AuthPinterestRequest extends AuthDefaultRequest {
|
||||
|
||||
@@ -43,10 +43,8 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
|
||||
|
||||
@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");
|
||||
@@ -58,7 +56,7 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.remark(userObj.getString("bio"))
|
||||
.token(authToken)
|
||||
.source(PINTEREST)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -82,6 +80,19 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
|
||||
.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查响应内容是否正确
|
||||
*
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AuthQqRequest extends AuthDefaultRequest {
|
||||
.uuid(openId)
|
||||
.gender(AuthUserGender.getRealGender(object.getString("gender")))
|
||||
.token(authToken)
|
||||
.source(AuthSource.QQ)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import static me.zhyd.oauth.model.AuthResponseStatus.SUCCESS;
|
||||
* 人人登录
|
||||
*
|
||||
* @author hongwei.peng (pengisgood(at)gmail(dot)com)
|
||||
* @version 1.8.1
|
||||
* @since 1.8.1
|
||||
* @version 1.9.0
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AuthRenrenRequest extends AuthDefaultRequest {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
|
||||
.company(getCompany(userObj))
|
||||
.gender(getGender(userObj))
|
||||
.token(authToken)
|
||||
.source(RENREN)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken 用户授权后的token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ import static me.zhyd.oauth.utils.GlobalAuthUtil.parseQueryToMap;
|
||||
*
|
||||
* @author hongwei.peng (pengisgood(at)gmail(dot)com)
|
||||
* @version 1.9.0
|
||||
* @since 1.9.0
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AuthStackOverflowRequest extends AuthDefaultRequest {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class AuthStackOverflowRequest extends AuthDefaultRequest {
|
||||
.blog(userObj.getString("website_url"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(STACK_OVERFLOW)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AuthTaobaoRequest extends AuthDefaultRequest {
|
||||
.nickname(nick)
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.TAOBAO)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
.email(object.getString("email"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(AuthSource.TEAMBITION)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AuthTencentCloudRequest extends AuthDefaultRequest {
|
||||
.email(object.getString("email"))
|
||||
.remark(object.getString("slogan"))
|
||||
.token(authToken)
|
||||
.source(AuthSource.TENCENT_CLOUD)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class AuthToutiaoRequest extends AuthDefaultRequest {
|
||||
.remark(user.getString("description"))
|
||||
.gender(AuthUserGender.getRealGender(user.getString("gender")))
|
||||
.token(authToken)
|
||||
.source(AuthSource.TOUTIAO)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AuthWeChatRequest extends AuthDefaultRequest {
|
||||
.uuid(openId)
|
||||
.gender(AuthUserGender.getRealGender(object.getString("sex")))
|
||||
.token(authToken)
|
||||
.source(AuthSource.WECHAT)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -69,14 +69,14 @@ public class AuthWeiboRequest extends AuthDefaultRequest {
|
||||
.remark(object.getString("description"))
|
||||
.gender(AuthUserGender.getRealGender(object.getString("gender")))
|
||||
.token(authToken)
|
||||
.source(AuthSource.WEIBO)
|
||||
.source(source)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken
|
||||
* @param authToken authToken
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,9 @@ public class AuthChecker {
|
||||
if (isSupported && AuthSource.ALIPAY == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getAlipayPublicKey());
|
||||
}
|
||||
if (isSupported && AuthSource.STACK_OVERFLOW == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getStackOverflowKey());
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GlobalAuthUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static String urlEncode(String value) {
|
||||
public static String urlEncode(String value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Map;
|
||||
* </p>
|
||||
*
|
||||
* @author yangkai.shen (https://xkcoding.com)
|
||||
* @date Created in 2019-07-18 15:47
|
||||
* @version 1.0
|
||||
* @since 1.8
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
@@ -60,4 +69,22 @@ public class CustomTest {
|
||||
// }
|
||||
return stackTrace[2].getMethodName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonpath(){
|
||||
List<Map<String, Map<String, Object>>> list = new ArrayList<>();
|
||||
|
||||
Map<String, Map<String, Object>> map = new HashMap<>();
|
||||
Map<String, Object> node = new HashMap<>();
|
||||
node.put("emailAddress", "xxxx");
|
||||
map.put("handle~", node);
|
||||
list.add(map);
|
||||
|
||||
|
||||
Map<String, Object> master = new HashMap<>();
|
||||
// master.put("elements", list);
|
||||
JSONObject emailObj = JSONObject.parseObject(JSON.toJSONString(master));
|
||||
Object object = JSONPath.eval(emailObj, "$['elements'][0]['handle~']['emailAddress']");
|
||||
System.out.println(object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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`枚举类
|
||||
@@ -7,7 +13,8 @@
|
||||
5. 优化`AuthConfig`、`AuthResponse`类,去掉不必要的lombonk注解,减少编译后的代码量
|
||||
6. 使用lombok注解优化枚举类
|
||||
7. `AuthQqRequest`增加refresh方法
|
||||
8. 优化代码
|
||||
8. 修复google登录无法获取用户信息的问题
|
||||
9. 优化代码
|
||||
|
||||
### 2019/07/18
|
||||
|
||||
|
||||
Reference in New Issue
Block a user