Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
justauth
JustAuth
提交
666d50b4
J
JustAuth
项目概览
justauth
/
JustAuth
1 年多 前同步成功
通知
394
Star
15212
Fork
2708
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JustAuth
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
666d50b4
编写于
7月 22, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into dev
上级
7515301f
798e7556
变更
33
隐藏空白更改
内联
并排
Showing
33 changed file
with
134 addition
and
73 deletion
+134
-73
README.md
README.md
+4
-4
pom.xml
pom.xml
+3
-3
src/main/java/me/zhyd/oauth/config/AuthSource.java
src/main/java/me/zhyd/oauth/config/AuthSource.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
+8
-2
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java
src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java
+4
-1
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
+2
-2
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+15
-10
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
+10
-6
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
+4
-8
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
+2
-2
src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
...main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
+3
-3
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
+2
-2
src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java
...main/java/me/zhyd/oauth/request/AuthPinterestRequest.java
+17
-6
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java
src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java
+4
-4
src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java
.../java/me/zhyd/oauth/request/AuthStackOverflowRequest.java
+2
-2
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java
...ain/java/me/zhyd/oauth/request/AuthTeambitionRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
...n/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
+1
-1
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+2
-2
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
+3
-0
src/main/java/me/zhyd/oauth/utils/GlobalAuthUtil.java
src/main/java/me/zhyd/oauth/utils/GlobalAuthUtil.java
+1
-1
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
+0
-1
src/test/java/me/zhyd/oauth/utils/CustomTest.java
src/test/java/me/zhyd/oauth/utils/CustomTest.java
+27
-0
update.md
update.md
+8
-1
未找到文件。
README.md
浏览文件 @
666d50b4
...
...
@@ -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.
等待作者合并
## 致谢
...
...
pom.xml
浏览文件 @
666d50b4
...
...
@@ -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>
\ No newline at end of file
</project>
src/main/java/me/zhyd/oauth/config/AuthSource.java
浏览文件 @
666d50b4
...
...
@@ -294,7 +294,7 @@ public enum AuthSource {
@Override
public
String
userInfo
()
{
return
"https://
oauth2.googleapis.com/token
info"
;
return
"https://
www.googleapis.com/oauth2/v3/user
info"
;
}
},
/**
...
...
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
浏览文件 @
666d50b4
...
...
@@ -81,7 +81,7 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
.
location
(
location
)
.
gender
(
AuthUserGender
.
getRealGender
(
response
.
getGender
()))
.
token
(
authToken
)
.
source
(
AuthSource
.
ALIPAY
)
.
source
(
source
)
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
);
...
...
src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
浏览文件 @
666d50b4
...
...
@@ -44,7 +44,7 @@ public class AuthCsdnRequest extends AuthDefaultRequest {
.
blog
(
object
.
getString
(
"website"
))
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
AuthSource
.
CSDN
)
.
source
(
source
)
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
)
{
...
...
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
浏览文件 @
666d50b4
...
...
@@ -42,7 +42,7 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
.
remark
(
userInfoObject
.
getString
(
"description"
))
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
AuthSource
.
DOUYIN
)
.
source
(
source
)
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
浏览文件 @
666d50b4
...
...
@@ -55,7 +55,7 @@ public class AuthGiteeRequest extends AuthDefaultRequest {
.
remark
(
object
.
getString
(
"bio"
))
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
AuthSource
.
GITEE
)
.
source
(
source
)
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
浏览文件 @
666d50b4
...
...
@@ -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"
));
}
}
}
src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
浏览文件 @
666d50b4
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"
));
}
}
}
src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
/**
* 检查响应内容是否正确
*
...
...
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
浏览文件 @
666d50b4
...
...
@@ -50,7 +50,7 @@ public class AuthTaobaoRequest extends AuthDefaultRequest {
.
nickname
(
nick
)
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
AuthSource
.
TAOBAO
)
.
source
(
source
)
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java
浏览文件 @
666d50b4
...
...
@@ -67,7 +67,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
.
email
(
object
.
getString
(
"email"
))
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
AuthSource
.
TEAMBITION
)
.
source
(
source
)
.
build
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
();
}
...
...
src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
浏览文件 @
666d50b4
...
...
@@ -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
...
...
src/main/java/me/zhyd/oauth/utils/AuthChecker.java
浏览文件 @
666d50b4
...
...
@@ -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
;
}
...
...
src/main/java/me/zhyd/oauth/utils/GlobalAuthUtil.java
浏览文件 @
666d50b4
...
...
@@ -45,7 +45,7 @@ public class GlobalAuthUtil {
}
}
p
rivate
static
String
urlEncode
(
String
value
)
{
p
ublic
static
String
urlEncode
(
String
value
)
{
if
(
value
==
null
)
{
return
""
;
}
...
...
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
浏览文件 @
666d50b4
...
...
@@ -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
*/
...
...
src/test/java/me/zhyd/oauth/utils/CustomTest.java
浏览文件 @
666d50b4
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
);
}
}
update.md
浏览文件 @
666d50b4
### 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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录