1
0
mirror of synced 2026-05-22 21:53:18 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
yadong.zhang 10df9f05f3 🔖 AuthUser添加构造函数,支持反序列化。发布1.10.1 2019-08-17 16:37:15 +08:00
yadong.zhang fd183afd4a 📝 Writing docs. 2019-08-08 19:16:19 +08:00
yadong.zhang d48a62d5cb Merge branch 'master' into dev 2019-08-07 11:02:12 +08:00
yadong.zhang b466dd8de3 🍻 add package-info 2019-08-07 10:54:36 +08:00
yadong.zhang cf77e4d0e0 🔀 合并分支 2019-08-06 18:14:35 +08:00
18 changed files with 117 additions and 13 deletions
+3 -3
View File
@@ -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.10.0-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.10.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/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.10.0-orange.svg" ></img>
<img src="https://img.shields.io/badge/Api Docs-1.10.1-orange.svg" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
@@ -91,7 +91,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
</dependency>
```
- 调用api
+3 -3
View File
@@ -9,7 +9,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.10.0-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.10.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>
@@ -18,7 +18,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/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.10.0-orange.svg" ></img>
<img src="https://img.shields.io/badge/Api Docs-1.10.1-orange.svg" ></img>
</a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
@@ -93,7 +93,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
</dependency>
```
- 调用api
+1 -1
View File
@@ -1,6 +1,6 @@
![](_media/logo.png)
# JustAuth <small>1.10.0</small>
# JustAuth <small>1.10.1</small>
<strong>史上最全的整合第三方登录的开源库</strong>
+9
View File
@@ -1,3 +1,12 @@
## v1.10.1
### 2019/08/17
- AuthUser添加构造函数,支持反序列化
### 2019/08/08
- 项目迁移到组织[justauth](https://github.com/justauth)
## v1.10.0
### 2019/08/06
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
<name>JustAuth</name>
<url>https://gitee.com/yadong.zhang/JustAuth</url>
+5
View File
@@ -0,0 +1,5 @@
/**
* JustAuth 缓存实现, 提供基础的基于ConcurrentHashMap + ScheduledExecutorService 实现的定时缓存。
* 同时对外暴露{@code AuthStateCache}接口,可进行对缓存实现的自定义。
*/
package me.zhyd.oauth.cache;
@@ -0,0 +1,4 @@
/**
* JustAuth 核心配置相关,包括{@code AuthConfig}和{@code AuthSource}
*/
package me.zhyd.oauth.config;
@@ -0,0 +1,4 @@
/**
* 提供一些必要的枚举类
*/
package me.zhyd.oauth.enums;
@@ -0,0 +1,4 @@
/**
* JustAuth专用异常封装
*/
package me.zhyd.oauth.exception;
@@ -0,0 +1,4 @@
/**
* 针对JustAuth简单封装的日志打印工具,可用过{@link me.zhyd.oauth.log.Log.Config}开关日志和指定日志级别
*/
package me.zhyd.oauth.log;
@@ -1,8 +1,6 @@
package me.zhyd.oauth.model;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthUserGender;
@@ -15,6 +13,8 @@ import me.zhyd.oauth.enums.AuthUserGender;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AuthUser {
/**
* 用户第三方系统的唯一id。在调用方集成改组件时,可以用uuid + source唯一确定一个用户
@@ -0,0 +1,4 @@
/**
* JustAuth核心模型类,封装了用户、token、响应和callback等实体类
*/
package me.zhyd.oauth.model;
@@ -0,0 +1,8 @@
/**
* JustAuth,如你所见,它仅仅是一个第三方授权登录的工具类库,它可以让我们脱离繁琐的第三方登录SDK,让登录变得So easy!
* <p>
* 史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、
* 支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、
* 人人、华为和企业微信等第三方平台的授权登录。 Login, so easy!
*/
package me.zhyd.oauth;
@@ -1,12 +1,20 @@
package me.zhyd.oauth.request;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.model.AuthToken;
/**
* JustAuth {@code Request}公共接口,所有平台的{@code Request}都需要实现该接口
* <p>
* {@link AuthRequest#authorize()}
* {@link AuthRequest#authorize(String)}
* {@link AuthRequest#login(AuthCallback)}
* {@link AuthRequest#revoke(AuthToken)}
* {@link AuthRequest#refresh(AuthToken)}
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @since 1.8
*/
@@ -0,0 +1,4 @@
/**
* JustAuth核心组件,所有授权登录都是基于{@code request}实现
*/
package me.zhyd.oauth.request;
@@ -0,0 +1,4 @@
/**
* 提供一些简单的工具和校验等
*/
package me.zhyd.oauth.utils;
@@ -283,7 +283,22 @@ public class AuthRequestTest {
AuthRequest authRequest = new AuthHuaweiRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.redirectUri("http://redirectUri")
.build());
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state1.8.0版本后,可以用AuthCallback类作为回调接口的入参
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@Test
public void weChatEnterpriseTest() {
AuthRequest authRequest = new AuthWeChatEnterpriseRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("http://redirectUri")
.agentId("agentId")
.build());
// 返回授权页面,可自行跳转
authRequest.authorize("state");
@@ -0,0 +1,31 @@
package me.zhyd.oauth.model;
import com.alibaba.fastjson.JSON;
import org.junit.Assert;
import org.junit.Test;
public class AuthUserTest {
@Test
public void serialize() {
AuthUser user = AuthUser.builder()
.nickname("test")
.build();
String json = JSON.toJSONString(user);
Assert.assertEquals(json, "{\"nickname\":\"test\"}");
}
@Test
public void deserialize() {
AuthUser user = AuthUser.builder()
.nickname("test")
.build();
String json = JSON.toJSONString(user);
AuthUser deserializeUser = JSON.parseObject(json, AuthUser.class);
Assert.assertEquals(deserializeUser.getNickname(), "test");
}
}