Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
justauth
JustAuth
提交
81ea4b16
J
JustAuth
项目概览
justauth
/
JustAuth
1 年多 前同步成功
通知
391
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看板
未验证
提交
81ea4b16
编写于
2月 26, 2023
作者:
智布道
👁
提交者:
GitHub
2月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #155 from marquis-chen/dev
企业微信网页登录--获取用户敏感信息
上级
f1714726
f3a8cf67
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
8 deletion
+37
-8
CHANGELOGS.md
CHANGELOGS.md
+10
-0
pom.xml
pom.xml
+1
-1
src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java
...yd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java
+23
-6
src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java
...me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java
+3
-1
未找到文件。
CHANGELOGS.md
浏览文件 @
81ea4b16
## 1.16.5
### 2021/10/18
-
合并 PR
[
Github #138
](
https://github.com/justauth/JustAuth/pull/138
)
-
升级alipay-sdk-version的依赖版本
-
修改用户logo的尺寸
-
修复 alipay 登录失败的 BUG
[
Gitee Issue #I4E4ML
](
https://gitee.com/yadong.zhang/JustAuth/issues/I4E4ML
)
## 1.16.4
### 2021/9/22
...
...
pom.xml
浏览文件 @
81ea4b16
...
...
@@ -60,7 +60,7 @@
<simple-http.version>
1.0.5
</simple-http.version>
<lombok-version>
1.18.20
</lombok-version>
<junit-version>
4.13.2
</junit-version>
<fastjson-version>
1.2.
78
</fastjson-version>
<fastjson-version>
1.2.
83
</fastjson-version>
<alipay-sdk-version>
4.17.5.ALL
</alipay-sdk-version>
<jacoco-version>
0.8.2
</jacoco-version>
</properties>
...
...
src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java
浏览文件 @
81ea4b16
...
...
@@ -3,7 +3,6 @@ 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.config.AuthSource
;
import
me.zhyd.oauth.enums.AuthResponseStatus
;
import
me.zhyd.oauth.enums.AuthUserGender
;
...
...
@@ -12,6 +11,7 @@ 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.StringUtils
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
...
...
@@ -56,8 +56,8 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq
throw
new
AuthException
(
AuthResponseStatus
.
UNIDENTIFIED_PLATFORM
,
source
);
}
String
userId
=
object
.
getString
(
"UserId"
);
String
user
DetailResponse
=
getUserDetail
(
authToken
.
getAccessToken
(),
userId
);
JSONObject
userDetail
=
this
.
checkResponse
(
userDetailResponse
);
String
user
Ticket
=
object
.
getString
(
"user_ticket"
);
JSONObject
userDetail
=
getUserDetail
(
authToken
.
getAccessToken
(),
userId
,
userTicket
);
return
AuthUser
.
builder
()
.
rawUserInfo
(
userDetail
)
...
...
@@ -123,14 +123,31 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq
*
* @param accessToken accessToken
* @param userId 企业内用户id
* @param userTicket 成员票据,用于获取用户信息或敏感信息
* @return 用户详情
*/
private
String
getUserDetail
(
String
accessToken
,
String
userId
)
{
String
userDetailUrl
=
UrlBuilder
.
fromBaseUrl
(
"https://qyapi.weixin.qq.com/cgi-bin/user/get"
)
private
JSONObject
getUserDetail
(
String
accessToken
,
String
userId
,
String
userTicket
)
{
// 用户基础信息
String
userInfoUrl
=
UrlBuilder
.
fromBaseUrl
(
"https://qyapi.weixin.qq.com/cgi-bin/user/get"
)
.
queryParam
(
"access_token"
,
accessToken
)
.
queryParam
(
"userid"
,
userId
)
.
build
();
return
new
HttpUtils
(
config
.
getHttpConfig
()).
get
(
userDetailUrl
).
getBody
();
String
userInfoResponse
=
new
HttpUtils
(
config
.
getHttpConfig
()).
get
(
userInfoUrl
).
getBody
();
JSONObject
userInfo
=
checkResponse
(
userInfoResponse
);
// 用户敏感信息
if
(
StringUtils
.
isNotEmpty
(
userTicket
))
{
String
userDetailUrl
=
UrlBuilder
.
fromBaseUrl
(
"https://qyapi.weixin.qq.com/cgi-bin/auth/getuserdetail"
)
.
queryParam
(
"access_token"
,
accessToken
)
.
build
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"user_ticket"
,
userTicket
);
String
userDetailResponse
=
new
HttpUtils
(
config
.
getHttpConfig
()).
post
(
userDetailUrl
,
param
.
toJSONString
()).
getBody
();
JSONObject
userDetail
=
checkResponse
(
userDetailResponse
);
userInfo
.
putAll
(
userDetail
);
}
return
userInfo
;
}
}
src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java
浏览文件 @
81ea4b16
...
...
@@ -5,6 +5,7 @@ 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.GlobalAuthUtils
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
...
...
@@ -28,7 +29,8 @@ public class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterprise
public
String
authorize
(
String
state
)
{
return
UrlBuilder
.
fromBaseUrl
(
source
.
authorize
())
.
queryParam
(
"appid"
,
config
.
getClientId
())
.
queryParam
(
"redirect_uri"
,
config
.
getRedirectUri
())
.
queryParam
(
"agentid"
,
config
.
getAgentId
())
.
queryParam
(
"redirect_uri"
,
GlobalAuthUtils
.
urlEncode
(
config
.
getRedirectUri
()))
.
queryParam
(
"response_type"
,
"code"
)
.
queryParam
(
"scope"
,
this
.
getScopes
(
","
,
false
,
AuthScopeUtils
.
getDefaultScopes
(
AuthWeChatEnterpriseWebScope
.
values
())))
.
queryParam
(
"state"
,
getRealState
(
state
).
concat
(
"#wechat_redirect"
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录