1
0
mirror of synced 2025-12-11 00:38:29 +08:00

Compare commits

...

7 Commits

Author SHA1 Message Date
yadong.zhang
eec26580c9 🚑 优化代码 2019-07-30 21:26:54 +08:00
yadong.zhang
421cabb176 🚑 优化代码 2019-07-30 21:19:55 +08:00
yadong.zhang
f71fce6858 Merge pull request #31 from xkcoding/refactor-1.9.3
调整部分代码
2019-07-30 21:15:50 +08:00
yadong.zhang
3199334ddc Merge branch 'dev' into refactor-1.9.3 2019-07-30 21:15:12 +08:00
yadong.zhang
79417395a1 🍻 升级hutool,alipay-sdk改为provided,添加注释,state校验 2019-07-30 21:10:00 +08:00
Yangkai.Shen
06934b5242 ♻️ 格式化代码 2019-07-30 18:47:14 +08:00
Yangkai.Shen
fcaef297ff ♻️ 修改部分代码 2019-07-30 18:41:34 +08:00
24 changed files with 95 additions and 47 deletions

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.9.3-blue.svg" ></img>
<img src="https://img.shields.io/badge/Maven Central-1.9.4-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.9.3-orange.svg" ></img>
<img src="https://img.shields.io/badge/Docs-1.9.4-orange.svg" ></img>
</a>
</p>
@@ -76,7 +76,7 @@ JustAuth如你所见它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.9.3</version>
<version>1.9.4</version>
</dependency>
```
- 调用api
@@ -90,7 +90,6 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
// 生成授权页面
authRequest.authorize();
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的参数
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(callback);
```

View File

@@ -6,7 +6,7 @@
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.9.3</version>
<version>1.9.4</version>
<name>JustAuth</name>
<url>https://gitee.com/yadong.zhang/JustAuth</url>
@@ -54,7 +54,7 @@
<maven-source.version>2.2.1</maven-source.version>
<maven-compiler.version>3.7.0</maven-compiler.version>
<maven.test.skip>true</maven.test.skip>
<hutool-version>4.6.0</hutool-version>
<hutool-version>4.6.1</hutool-version>
<lombok-version>1.18.4</lombok-version>
<junit-version>4.11</junit-version>
<fastjson-version>1.2.58</fastjson-version>
@@ -89,7 +89,7 @@
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>${alipay-sdk-version}</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@@ -1,7 +1,7 @@
package me.zhyd.oauth.config;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthResponseStatus;
/**
* 各api需要的url 用枚举类分平台类型管理

View File

@@ -1,15 +1,21 @@
package me.zhyd.oauth.model;
package me.zhyd.oauth.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* JustAuth通用的状态码对照表
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @since 1.8
*/
@Getter
@AllArgsConstructor
public enum AuthResponseStatus {
/**
* 2000正常
* other调用异常具体异常内容见{@code msg}
*/
SUCCESS(2000, "Success"),
FAILURE(5000, "Failure"),
NOT_IMPLEMENTED(5001, "Not Implemented"),

View File

@@ -12,6 +12,10 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum AuthToutiaoErrorCode {
/**
* 0正常
* other调用异常具体异常内容见{@code desc}
*/
EC0(0, "接口调用成功"),
EC1(1, "API配置错误未传入Client Key"),
EC2(2, "API配置错误Client Key错误请检查是否和开放平台的ClientKey一致"),

View File

@@ -14,7 +14,14 @@ import java.util.Arrays;
@Getter
@AllArgsConstructor
public enum AuthUserGender {
MALE(1, ""), FEMALE(0, ""), UNKNOWN(-1, "未知");
/**
* MALE/FAMALE为正常值通过{@link AuthUserGender#getRealGender(String)}方法获取真实的性别
* UNKNOWN为容错值部分平台不会返回用户性别为了方便统一使用UNKNOWN标记所有未知或不可测的用户性别信息
*/
MALE(1, ""),
FEMALE(0, ""),
UNKNOWN(-1, "未知");
private int code;
private String desc;

View File

@@ -1,8 +1,10 @@
package me.zhyd.oauth.exception;
import me.zhyd.oauth.model.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthResponseStatus;
/**
* JustAuth通用异常类
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @since 1.8
*/

View File

@@ -2,7 +2,6 @@ package me.zhyd.oauth.model;
import lombok.Getter;
import lombok.Setter;
import me.zhyd.oauth.cache.AuthStateCache;
/**
* 授权回调时的参数类
@@ -28,14 +27,4 @@ public class AuthCallback {
* 访问AuthorizeUrl后回调时带的参数state用于和请求AuthorizeUrl前的state比较防止CSRF攻击
*/
private String state;
/**
* 内置的检验state合法性的方法
*
* @return true state正常falsestate不正常可能授权时间过长导致state失效
* @since 1.9.3
*/
public boolean checkState() {
return AuthStateCache.containsKey(this.state);
}
}

View File

@@ -2,7 +2,7 @@ package me.zhyd.oauth.model;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import me.zhyd.oauth.enums.AuthResponseStatus;
/**
* JustAuth统一授权响应类

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -6,8 +6,12 @@ import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
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.AuthChecker;
import me.zhyd.oauth.utils.StringUtils;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -35,14 +39,37 @@ public abstract class AuthDefaultRequest implements AuthRequest {
AuthChecker.checkConfig(config, source);
}
/**
* 获取access token
*
* @param authCallback 授权成功后的回调参数
* @return token
* @see AuthDefaultRequest#authorize()
* @see AuthDefaultRequest#authorize(String)
*/
protected abstract AuthToken getAccessToken(AuthCallback authCallback);
/**
* 使用token换取用户信息
*
* @param authToken token信息
* @return 用户信息
* @see AuthDefaultRequest#getAccessToken(AuthCallback)
*/
protected abstract AuthUser getUserInfo(AuthToken authToken);
/**
* 统一的登录入口。当通过{@link AuthDefaultRequest#authorize(String)}授权成功后,会跳转到调用方的相关回调方法中
* 方法的入参可以使用{@code AuthCallback}{@code AuthCallback}类中封装好了OAuth2授权回调所需要的参数
*
* @param authCallback 用于接收回调参数的实体
* @return AuthResponse
*/
@Override
public AuthResponse login(AuthCallback authCallback) {
try {
AuthChecker.checkCode(source == AuthSource.ALIPAY ? authCallback.getAuth_code() : authCallback.getCode());
AuthChecker.checkState(authCallback.getState());
AuthToken authToken = this.getAccessToken(authCallback);
AuthUser user = this.getUserInfo(authToken);
@@ -53,6 +80,12 @@ public abstract class AuthDefaultRequest implements AuthRequest {
}
}
/**
* 处理{@link AuthDefaultRequest#login(AuthCallback)} 发生异常的情况,统一响应参数
*
* @param e 具体的异常
* @return AuthResponse
*/
private AuthResponse responseError(Exception e) {
int errorCode = AuthResponseStatus.FAILURE.getCode();
if (e instanceof AuthException) {

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -7,6 +7,7 @@ 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.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
@@ -112,7 +113,6 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
* @return 用户的邮箱地址
*/
private String getUserEmail(String accessToken) {
String email = null;
HttpResponse emailResponse = HttpRequest.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))")
.header("Host", "api.linkedin.com")
.header("Connection", "Keep-Alive")

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -92,6 +92,7 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
* @param authToken token
* @return 返回获取userInfo的url
*/
@Override
protected String userInfoUrl(AuthToken authToken) {
return UrlBuilder.fromBaseUrl(source.userInfo())
.queryParam("access_token", authToken.getAccessToken())

View File

@@ -6,6 +6,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -13,7 +13,7 @@ import me.zhyd.oauth.utils.UrlBuilder;
import java.util.Objects;
import static me.zhyd.oauth.config.AuthSource.RENREN;
import static me.zhyd.oauth.model.AuthResponseStatus.SUCCESS;
import static me.zhyd.oauth.enums.AuthResponseStatus.SUCCESS;
/**
* 人人登录

View File

@@ -3,7 +3,7 @@ package me.zhyd.oauth.request;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.model.AuthToken;
/**

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;

View File

@@ -1,9 +1,10 @@
package me.zhyd.oauth.utils;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthResponseStatus;
/**
* 授权配置类的校验器
@@ -65,4 +66,15 @@ public class AuthChecker {
throw new AuthException(AuthResponseStatus.ILLEGAL_CODE);
}
}
/**
* 校验回调传回的state
*
* @param state {@code state}一定不为空
*/
public static void checkState(String state) {
if (StringUtils.isEmpty(state) || !AuthStateCache.containsKey(state)) {
throw new AuthException(AuthResponseStatus.ILLEGAL_REQUEST);
}
}
}

View File

@@ -21,7 +21,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -36,7 +35,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -51,7 +49,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -66,7 +63,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -81,7 +77,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -96,7 +91,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -111,7 +105,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -126,7 +119,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
authRequest.login(new AuthCallback());
}
@@ -142,7 +134,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -157,7 +148,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -172,7 +162,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -187,7 +176,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -202,7 +190,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -217,7 +204,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -232,7 +218,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -247,7 +232,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -262,7 +246,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -277,7 +260,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}
@@ -292,7 +274,6 @@ public class AuthRequestTest {
// 返回授权页面,可自行跳转
authRequest.authorize("state");
// 授权登录后会返回codeauth_code仅限支付宝、state1.8.0版本后可以用AuthCallback类作为回调接口的入参
// 1.9.3版本后 如果需要验证state可以在login之前调用{@see AuthCallback#checkState}方法校验state合法性
// 注JustAuth默认保存state的时效为3分钟3分钟内未使用则会自动清除过期的state
AuthResponse login = authRequest.login(new AuthCallback());
}

View File

@@ -1,3 +1,10 @@
### 2019/07/30 [v1.9.4](https://gitee.com/yadong.zhang/JustAuth/releases/v1.9.4)
1. 升级`hutool-http`版本到`v4.6.1`
2. 去除`AuthCallback`中增加的默认的校验state的方法挪到`AuthDefaultRequest`中做统一处理
3. `alipay-sdk-java`依赖改为`provided`如果需要使用支付宝登录需要使用方手动引入相关依赖具体操作方式见项目WIKI
4. 规范注释
### 2019/07/30 [v1.9.3](https://gitee.com/yadong.zhang/JustAuth/releases/v1.9.3)
1. 规范注释