diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2345405 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +## 版本更新记录 + +### 【0.0.2】2019-08-01 + +- 升级 `JustAuth` 版本:1.9.5 + +### 【0.0.1】2019-07-23 + +- 使用 `JustAuth` 版本:1.9.2 + diff --git a/README.md b/README.md index 78ee939..9870344 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ https://github.com/xkcoding/justauth-spring-boot-starter-demo com.xkcoding justauth-spring-boot-starter - 0.0.1 + 0.0.2 ``` @@ -41,31 +41,7 @@ justauth: - 然后就开始玩耍吧~ ```java -package com.xkcoding.justauthspringbootstarterdemo; - -import com.xkcoding.justauth.AuthRequestFactory; -import lombok.RequiredArgsConstructor; -import me.zhyd.oauth.config.AuthSource; -import me.zhyd.oauth.model.AuthCallback; -import me.zhyd.oauth.model.AuthResponse; -import me.zhyd.oauth.request.AuthRequest; -import me.zhyd.oauth.utils.AuthState; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

- * 测试 Controller - *

- * - * @author yangkai.shen - * @date Created in 2019-07-22 11:17 - */ +@Slf4j @RestController @RequestMapping("/oauth") @RequiredArgsConstructor(onConstructor_ = @Autowired) @@ -75,15 +51,14 @@ public class TestController { @GetMapping("/login/qq") public void login(HttpServletResponse response) throws IOException { AuthRequest authRequest = factory.get(AuthSource.QQ); - response.sendRedirect(authRequest.authorize()); + response.sendRedirect(authRequest.authorize(AuthStateUtils.createState())); } @RequestMapping("/qq/callback") public AuthResponse login(AuthCallback callback) { - AuthRequest authRequest = factory.get(AuthSource.QQ); - AuthResponse response = authRequest.login(callback); - // 移除校验通过的state - AuthState.delete(AuthSource.QQ); + AuthRequest authRequest2 = factory.get(AuthSource.QQ); + AuthResponse response = authRequest2.login(callback); + log.info("【response】= {}", JSONUtil.toJsonStr(response)); return response; } } diff --git a/pom.xml b/pom.xml index 3aa07f1..c228450 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.xkcoding justauth-spring-boot-starter - 0.0.2-SNAPSHOT + 0.0.2 justauth-spring-boot-starter https://github.com/xkcoding/justauth-spring-boot-starter @@ -50,7 +50,7 @@ 2.1.6.RELEASE - 1.9.3-SNAPSHOT + 1.9.5 diff --git a/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java b/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java index 034ca61..842ee9f 100644 --- a/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java +++ b/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java @@ -4,8 +4,9 @@ import lombok.RequiredArgsConstructor; 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.request.*; -import me.zhyd.oauth.utils.AuthState; /** *

@@ -26,19 +27,7 @@ public class AuthRequestFactory { * @return {@link AuthRequest} */ public AuthRequest get(AuthSource source) { - return get(source, null); - } - - /** - * 返回AuthRequest对象 - * - * @param source {@link AuthSource} - * @param state {@link AuthSource} - * @return {@link AuthRequest} - */ - public AuthRequest get(AuthSource source, Object state) { AuthConfig config = properties.getType().get(source); - config.setState(state == null ? AuthState.create(source) : AuthState.create(source, state)); switch (source) { case GITHUB: return new AuthGithubRequest(config); @@ -89,7 +78,7 @@ public AuthRequest get(AuthSource source, Object state) { case STACK_OVERFLOW: return new AuthStackOverflowRequest(config); default: - return null; + throw new AuthException(AuthResponseStatus.UNSUPPORTED); } } }