mirror of
https://gitee.com/yadong.zhang/JustAuth.git
synced 2025-12-06 08:48:27 +08:00
💩 去掉非强制的依赖项
This commit is contained in:
parent
04400f55dc
commit
89fc9903e5
6
pom.xml
6
pom.xml
@ -43,7 +43,6 @@
|
||||
<hutool-version>4.1.21</hutool-version>
|
||||
<lombok-version>1.18.4</lombok-version>
|
||||
<junit-version>4.11</junit-version>
|
||||
<servlet-api-version>2.5</servlet-api-version>
|
||||
<fastjson-version>1.2.44</fastjson-version>
|
||||
<google-api-version>1.28.0</google-api-version>
|
||||
</properties>
|
||||
@ -65,11 +64,6 @@
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>${servlet-api-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
|
||||
@ -3,9 +3,6 @@ package me.zhyd.oauth.request;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
@ -15,15 +12,6 @@ import java.io.IOException;
|
||||
*/
|
||||
public interface AuthRequest {
|
||||
|
||||
/**
|
||||
* 自动跳转到认证页面
|
||||
*
|
||||
* @param response response
|
||||
*/
|
||||
default void authorize(HttpServletResponse response) throws IOException {
|
||||
throw new AuthException(ResponseStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回认证url,可自行跳转页面
|
||||
*/
|
||||
|
||||
@ -13,8 +13,6 @@ import me.zhyd.oauth.utils.IpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
|
||||
@ -9,9 +9,6 @@ import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.AuthConfigChecker;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
@ -43,11 +40,6 @@ public abstract class BaseAuthRequest implements AuthRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorize(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect(this.authorize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize() {
|
||||
String authorizeUrl = null;
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
@ -16,15 +16,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class AuthRequestTest {
|
||||
|
||||
@Test
|
||||
public void giteeTest() {
|
||||
HttpServletResponse response = null;
|
||||
public void giteeTest() throws IOException {
|
||||
AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
|
||||
.clientId("clientId")
|
||||
.clientSecret("clientSecret")
|
||||
.redirectUri("redirectUri")
|
||||
.build());
|
||||
// 自动跳转到授权页面
|
||||
authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
authRequest.authorize();
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
@ -32,15 +29,12 @@ public class AuthRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void githubTest() {
|
||||
HttpServletResponse response = null;
|
||||
public void githubTest() throws IOException {
|
||||
AuthRequest authRequest = new AuthGithubRequest(AuthConfig.builder()
|
||||
.clientId("clientId")
|
||||
.clientSecret("clientSecret")
|
||||
.redirectUri("redirectUri")
|
||||
.build());
|
||||
// 自动跳转到授权页面
|
||||
authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
authRequest.authorize();
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
@ -48,15 +42,12 @@ public class AuthRequestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void weiboTest() {
|
||||
HttpServletResponse response = null;
|
||||
public void weiboTest() throws IOException {
|
||||
AuthRequest authRequest = new AuthWeiboRequest(AuthConfig.builder()
|
||||
.clientId("clientId")
|
||||
.clientSecret("clientSecret")
|
||||
.redirectUri("redirectUri")
|
||||
.build());
|
||||
// 自动跳转到授权页面
|
||||
authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
authRequest.authorize();
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
@ -65,14 +56,11 @@ public class AuthRequestTest {
|
||||
|
||||
@Test
|
||||
public void dingdingTest() {
|
||||
HttpServletResponse response = null;
|
||||
AuthRequest authRequest = new AuthDingTalkRequest(AuthConfig.builder()
|
||||
.clientId("dingoa2q6o3fomfk6vdqzy")
|
||||
.clientSecret("d5w75-R-yNtQsq_Ya_r50gOsKOy9WlmrlUOJkUJXKvsQp7NDPRHsj0epJriiN3yO")
|
||||
.redirectUri("http://61.149.7.121:8443/oauth/dingtalk/callback")
|
||||
.build());
|
||||
// 自动跳转到授权页面
|
||||
// authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
String url = authRequest.authorize();
|
||||
System.out.println(url);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user