...
 
Commits (13)
    https://gitcode.net/justauth/JustAuth/-/commit/02674049d02c30132deceea10728a185e780e0fa :memo: 更新说明 2021-10-18T10:03:14+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/justauth/JustAuth/-/commit/e1b912bdf6792807a026c09ff4ee9a4826f47a0e :arrow_up: Bump fastjson from 1.2.78 to 1.2.83 2022-06-17T02:05:50+00:00 dependabot[bot] 49699333+dependabot[bot]@users.noreply.github.com Bumps [fastjson](<a href="https://github.com/alibaba/fastjson" rel="nofollow noreferrer noopener" target="_blank">https://github.com/alibaba/fastjson</a>) from 1.2.78 to 1.2.83. - [Release notes](<a href="https://github.com/alibaba/fastjson/releases" rel="nofollow noreferrer noopener" target="_blank">https://github.com/alibaba/fastjson/releases</a>) - [Commits](<a href="https://github.com/alibaba/fastjson/compare/1.2.78...1.2.83" rel="nofollow noreferrer noopener" target="_blank">https://github.com/alibaba/fastjson/compare/1.2.78...1.2.83</a>) --- updated-dependencies: - dependency-name: com.alibaba:fastjson dependency-type: direct:production ... Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:support@github.com" title="support@github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:support@github.com" title="support@github.com">dependabot[bot]</a> &lt;<a href="mailto:support@github.com" title="support@github.com">support@github.com</a>&gt;</span> https://gitcode.net/justauth/JustAuth/-/commit/571466f07968ca866482d5cd6d2365b03f81fd1b Merge pull request #149 from justauth/dependabot/maven/com.alibaba-fastjson-1... 2022-08-07T22:59:14+08:00 yadong.zhang yadong.zhang0415@gmail.com <gl-emoji title="upwards black arrow" data-name="arrow_up" data-unicode-version="4.0">⬆</gl-emoji>️ Bump fastjson from 1.2.78 to 1.2.83 https://gitcode.net/justauth/JustAuth/-/commit/f3a8cf675c9203aeabbe1faefb6216177ac28d0c 企业微信网页登录增加AgentId参数,对重定向地址UrlEncode,获取用户敏感信息 2022-09-05T16:42:51+08:00 marquis chen 838095230@qq.com https://gitcode.net/justauth/JustAuth/-/commit/7a9d602499894df1977d87d7e3c74e032bc8941b test:添加飞书单元测试 2022-10-03T13:17:28+08:00 chengpengxiang 15503679582@163.com https://gitcode.net/justauth/JustAuth/-/commit/bac494a7fc2679c1beb23dea1720803645ee9afe 修复企业微信的 redirect_uri 没有 urlEncode 问题 2022-10-21T16:22:13+08:00 alexchan alexchan0611@gmail.com https://gitcode.net/justauth/JustAuth/-/commit/afddf269e188e92161357b3eb9627c7cb8141a4c !31 修复企业微信的 redirect_uri 没有 urlEncode 问题 2022-10-23T12:06:06+00:00 yadong.zhang yadong.zhang0415@gmail.com Merge pull request !31 from AlexChan/dev https://gitcode.net/justauth/JustAuth/-/commit/e80304601f5367426c2ff9f0863a3780c80ac952 update pom.xml. 2023-02-24T11:54:47+00:00 test 531648642@qq.com 升级fastjson版本到1.2.83,1.2.83版本之前存在代码执行漏洞风险 ,CVE-2022-25845 Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:531648642@qq.com" title="531648642@qq.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:531648642@qq.com" title="531648642@qq.com">test</a> &lt;<a href="mailto:531648642@qq.com" title="531648642@qq.com">531648642@qq.com</a>&gt;</span> https://gitcode.net/justauth/JustAuth/-/commit/cc74d4a5c8b47d6c1983267215f7cb9981690d5d !33 【轻量级 PR】:update pom.xml. 2023-02-24T12:15:56+00:00 yadong.zhang yadong.zhang0415@gmail.com Merge pull request !33 from test/N/A https://gitcode.net/justauth/JustAuth/-/commit/81ea4b1620dd38383b13582424d4466607eb97db Merge pull request #155 from marquis-chen/dev 2023-02-26T16:19:28+08:00 yadong.zhang yadong.zhang0415@gmail.com 企业微信网页登录--获取用户敏感信息 https://gitcode.net/justauth/JustAuth/-/commit/ca8e194c4ebc2fc38dafd1b7cc70531cc00e29f3 Merge pull request #159 from cheng521521/master 2023-02-26T16:19:58+08:00 yadong.zhang yadong.zhang0415@gmail.com 添加飞书单元测试 https://gitcode.net/justauth/JustAuth/-/commit/0bc4c806bfb254f1cd1e7319ae0cd6e8a3cecadb :arrow_up: Merge branch 'dev' 2023-02-26T16:47:27+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/justauth/JustAuth/-/commit/3564c846f41f6fbdbc92033f7e9f9704830fe010 Merge branch 'master' of gitee.com:yadong.zhang/JustAuth into dev 2023-02-26T16:47:46+08:00 yadong.zhang yadong.zhang0415@gmail.com
## 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 ## 1.16.4
### 2021/9/22 ### 2021/9/22
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<simple-http.version>1.0.5</simple-http.version> <simple-http.version>1.0.5</simple-http.version>
<lombok-version>1.18.20</lombok-version> <lombok-version>1.18.20</lombok-version>
<junit-version>4.13.2</junit-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> <alipay-sdk-version>4.17.5.ALL</alipay-sdk-version>
<jacoco-version>0.8.2</jacoco-version> <jacoco-version>0.8.2</jacoco-version>
</properties> </properties>
......
...@@ -3,7 +3,6 @@ package me.zhyd.oauth.request; ...@@ -3,7 +3,6 @@ package me.zhyd.oauth.request;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.cache.AuthStateCache; import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.config.AuthConfig; import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthDefaultSource;
import me.zhyd.oauth.config.AuthSource; import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus; import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender; import me.zhyd.oauth.enums.AuthUserGender;
...@@ -12,6 +11,7 @@ import me.zhyd.oauth.model.AuthCallback; ...@@ -12,6 +11,7 @@ import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthToken; import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser; import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.utils.HttpUtils; import me.zhyd.oauth.utils.HttpUtils;
import me.zhyd.oauth.utils.StringUtils;
import me.zhyd.oauth.utils.UrlBuilder; import me.zhyd.oauth.utils.UrlBuilder;
/** /**
...@@ -56,8 +56,8 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq ...@@ -56,8 +56,8 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq
throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM, source); throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM, source);
} }
String userId = object.getString("UserId"); String userId = object.getString("UserId");
String userDetailResponse = getUserDetail(authToken.getAccessToken(), userId); String userTicket = object.getString("user_ticket");
JSONObject userDetail = this.checkResponse(userDetailResponse); JSONObject userDetail = getUserDetail(authToken.getAccessToken(), userId, userTicket);
return AuthUser.builder() return AuthUser.builder()
.rawUserInfo(userDetail) .rawUserInfo(userDetail)
...@@ -123,14 +123,31 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq ...@@ -123,14 +123,31 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq
* *
* @param accessToken accessToken * @param accessToken accessToken
* @param userId 企业内用户id * @param userId 企业内用户id
* @param userTicket 成员票据,用于获取用户信息或敏感信息
* @return 用户详情 * @return 用户详情
*/ */
private String getUserDetail(String accessToken, String userId) { private JSONObject getUserDetail(String accessToken, String userId, String userTicket) {
String userDetailUrl = UrlBuilder.fromBaseUrl("https://qyapi.weixin.qq.com/cgi-bin/user/get") // 用户基础信息
String userInfoUrl = UrlBuilder.fromBaseUrl("https://qyapi.weixin.qq.com/cgi-bin/user/get")
.queryParam("access_token", accessToken) .queryParam("access_token", accessToken)
.queryParam("userid", userId) .queryParam("userid", userId)
.build(); .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;
} }
} }
...@@ -5,6 +5,7 @@ import me.zhyd.oauth.config.AuthConfig; ...@@ -5,6 +5,7 @@ import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthDefaultSource; import me.zhyd.oauth.config.AuthDefaultSource;
import me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope; import me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope;
import me.zhyd.oauth.utils.AuthScopeUtils; import me.zhyd.oauth.utils.AuthScopeUtils;
import me.zhyd.oauth.utils.GlobalAuthUtils;
import me.zhyd.oauth.utils.UrlBuilder; import me.zhyd.oauth.utils.UrlBuilder;
/** /**
...@@ -28,7 +29,8 @@ public class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterprise ...@@ -28,7 +29,8 @@ public class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterprise
public String authorize(String state) { public String authorize(String state) {
return UrlBuilder.fromBaseUrl(source.authorize()) return UrlBuilder.fromBaseUrl(source.authorize())
.queryParam("appid", config.getClientId()) .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("response_type", "code")
.queryParam("scope", this.getScopes(",", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values()))) .queryParam("scope", this.getScopes(",", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values())))
.queryParam("state", getRealState(state).concat("#wechat_redirect")) .queryParam("state", getRealState(state).concat("#wechat_redirect"))
......
package me.zhyd.oauth.request;
import com.alibaba.fastjson.JSON;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.junit.Assert;
import org.junit.Test;
/**
* @ClassName AuthFeiShuRequestTest
* @Author jackcheng(chen781142032@gamil.com)
* @version 1.0
* @since 1.16.5
* @Date 2022/10/1 11:23
* @Description 飞书第三方登录测试类 先执行authorize()方法获取state以及authorizeUrl,
* 然后在浏览器中打开authorizeUrl,登录成功后会跳转到redirectUri,并且会携带code和state参数
**/
public class AuthFeiShuRequestTest {
@Test
public void authorize() {
AuthRequest request = new AuthFeishuRequest(AuthConfig.builder()
.clientId("your App ID")
.clientSecret("your App Secret")
.redirectUri("you set redirect uri")
.build());
String state = AuthStateUtils.createState();
System.out.println("state==" + state);
String authorize = request.authorize(state);
System.out.println("authorize==" + authorize);
Assert.assertNotNull(authorize);
}
@Test
public void getAccessTokenAndUserInfo() {
AuthRequest request = new AuthFeishuRequest(AuthConfig.builder()
.clientId("your App ID")
.clientSecret("your App Secret")
.redirectUri("you set redirect uri")
.build());
String state = "your state";
AuthCallback callback = AuthCallback.builder()
.code("your code")
.state(state)
.build();
AuthToken accessToken = ((AuthFeishuRequest) request).getAccessToken(callback);
Assert.assertNotNull(accessToken);
System.out.println("token==" + accessToken.getAccessToken());
AuthUser userInfo = ((AuthFeishuRequest) request).getUserInfo(accessToken);
Assert.assertNotNull(userInfo);
System.out.println("userInfo==" + JSON.toJSONString(userInfo));
}
@Test
public void login() {
AuthRequest request = new AuthFeishuRequest(AuthConfig.builder()
.clientId("your App ID")
.clientSecret("your App Secret")
.redirectUri("you set redirect uri")
.build());
String state = "your state";
request.authorize(state);
AuthCallback callback = AuthCallback.builder()
.code("your code")
.state(state)
.build();
AuthResponse response = request.login(callback);
Assert.assertNotNull(response);
AuthUser user = (AuthUser) response.getData();
Assert.assertNotNull(user);
System.out.println(JSON.toJSONString(user));
}
}
package me.zhyd.oauth.request;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.junit.Test;
import static org.junit.Assert.*;
public class AuthWeChatEnterpriseWebRequestTest {
@Test
public void authorize() {
AuthRequest request = new AuthWeChatEnterpriseWebRequest(AuthConfig.builder()
.clientId("a")
.clientSecret("a")
.redirectUri("https://www.justauth.cn")
.build());
System.out.println(request.authorize(AuthStateUtils.createState()));
}
}