⬆️ 升级 JustAuth 版本为 1.9.5
This commit is contained in:
10
CHANGELOG.md
Normal file
10
CHANGELOG.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## 版本更新记录
|
||||
|
||||
### 【0.0.2】2019-08-01
|
||||
|
||||
- 升级 `JustAuth` 版本:1.9.5
|
||||
|
||||
### 【0.0.1】2019-07-23
|
||||
|
||||
- 使用 `JustAuth` 版本:1.9.2
|
||||
|
||||
37
README.md
37
README.md
@@ -22,7 +22,7 @@ https://github.com/xkcoding/justauth-spring-boot-starter-demo
|
||||
<dependency>
|
||||
<groupId>com.xkcoding</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.2</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 测试 Controller
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.xkcoding</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<version>0.0.2</version>
|
||||
|
||||
<name>justauth-spring-boot-starter</name>
|
||||
<url>https://github.com/xkcoding/justauth-spring-boot-starter</url>
|
||||
@@ -50,7 +50,7 @@
|
||||
<!--SpringBoot版本-->
|
||||
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
|
||||
<!--JustAuth版本-->
|
||||
<justauth.version>1.9.3-SNAPSHOT</justauth.version>
|
||||
<justauth.version>1.9.5</justauth.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -4,8 +4,9 @@ import com.xkcoding.justauth.properties.JustAuthProperties;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -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 class AuthRequestFactory {
|
||||
case STACK_OVERFLOW:
|
||||
return new AuthStackOverflowRequest(config);
|
||||
default:
|
||||
return null;
|
||||
throw new AuthException(AuthResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user