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