👽 更新api调用方式、更新文档
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
* @website https://www.zhyd.me
|
||||
* @date 2019/2/14 13:34
|
||||
* @since 1.8
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
public class GiteeConfig extends AuthConfig {
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
* @website https://www.zhyd.me
|
||||
* @date 2019/2/14 13:34
|
||||
* @since 1.8
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
public class GithubConfig extends AuthConfig {
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
* @website https://www.zhyd.me
|
||||
* @date 2019/2/14 13:34
|
||||
* @since 1.8
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
@Deprecated
|
||||
public class QqConfig extends AuthConfig {
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
* @website https://www.zhyd.me
|
||||
* @date 2019/2/14 13:34
|
||||
* @since 1.8
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
@Deprecated
|
||||
public class WechatConfig extends AuthConfig {
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
* @website https://www.zhyd.me
|
||||
* @date 2019/2/14 13:34
|
||||
* @since 1.8
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
public class WeiboConfig extends AuthConfig {
|
||||
}
|
||||
@@ -21,10 +21,14 @@ import java.io.IOException;
|
||||
* @date 2019/1/31 16:31
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AuthGiteeRequest implements AuthRequest {
|
||||
public class AuthGiteeRequest extends BaseAuthRequest implements AuthRequest {
|
||||
|
||||
public AuthGiteeRequest(AuthConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorize(AuthConfig config, HttpServletResponse response) {
|
||||
public void authorize(HttpServletResponse response) {
|
||||
if (!AuthConfigChecker.isSupportedGitee()) {
|
||||
throw new AuthException(ResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
@@ -37,7 +41,7 @@ public class AuthGiteeRequest implements AuthRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(AuthConfig config) {
|
||||
public String authorize() {
|
||||
if (!AuthConfigChecker.isSupportedGitee()) {
|
||||
throw new AuthException(ResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
@@ -45,7 +49,7 @@ public class AuthGiteeRequest implements AuthRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse login(AuthConfig config, String code) {
|
||||
public AuthResponse login(String code) {
|
||||
if (!AuthConfigChecker.isSupportedGitee()) {
|
||||
return AuthResponse.builder()
|
||||
.code(ResponseStatus.UNSUPPORTED.getCode())
|
||||
|
||||
@@ -21,10 +21,14 @@ import java.io.IOException;
|
||||
* @date 2019/1/31 16:31
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AuthGithubRequest implements AuthRequest {
|
||||
public class AuthGithubRequest extends BaseAuthRequest implements AuthRequest {
|
||||
|
||||
public AuthGithubRequest(AuthConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorize(AuthConfig config, HttpServletResponse response) {
|
||||
public void authorize(HttpServletResponse response) {
|
||||
if (!AuthConfigChecker.isSupportedGithub()) {
|
||||
throw new AuthException(ResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
@@ -37,7 +41,7 @@ public class AuthGithubRequest implements AuthRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(AuthConfig config) {
|
||||
public String authorize() {
|
||||
if (!AuthConfigChecker.isSupportedGithub()) {
|
||||
throw new AuthException(ResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
@@ -45,7 +49,7 @@ public class AuthGithubRequest implements AuthRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse login(AuthConfig config, String code) {
|
||||
public AuthResponse login(String code) {
|
||||
if (!AuthConfigChecker.isSupportedGithub()) {
|
||||
return AuthResponse.builder()
|
||||
.code(ResponseStatus.UNSUPPORTED.getCode())
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
|
||||
@@ -18,30 +17,26 @@ public interface AuthRequest {
|
||||
/**
|
||||
* 自动跳转到认证页面
|
||||
*
|
||||
* @param config 授权的配置,对应不同平台
|
||||
* @param response response
|
||||
*/
|
||||
default void authorize(AuthConfig config, HttpServletResponse response) {
|
||||
default void authorize(HttpServletResponse response) {
|
||||
throw new AuthException(ResponseStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回认证url,可自行跳转页面
|
||||
*
|
||||
* @param config 授权的配置,对应不同平台
|
||||
*/
|
||||
default String authorize(AuthConfig config) {
|
||||
default String authorize() {
|
||||
throw new AuthException(ResponseStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方登录
|
||||
*
|
||||
* @param config 授权的配置,对应不同平台
|
||||
* @param code 通过authorize换回的code
|
||||
* @param code 通过authorize换回的code
|
||||
* @return 返回登陆成功后的用户信息
|
||||
*/
|
||||
default AuthResponse login(AuthConfig config, String code) {
|
||||
default AuthResponse login(String code) {
|
||||
throw new AuthException(ResponseStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,14 @@ import java.io.IOException;
|
||||
* @date 2019/1/31 16:31
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AuthWeiboRequest implements AuthRequest {
|
||||
public class AuthWeiboRequest extends BaseAuthRequest implements AuthRequest {
|
||||
|
||||
public AuthWeiboRequest(AuthConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorize(AuthConfig config, HttpServletResponse response) {
|
||||
public void authorize(HttpServletResponse response) {
|
||||
if (!AuthConfigChecker.isSupportedWeibo()) {
|
||||
throw new AuthException(ResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
@@ -40,7 +44,7 @@ public class AuthWeiboRequest implements AuthRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(AuthConfig config) {
|
||||
public String authorize() {
|
||||
if (!AuthConfigChecker.isSupportedWeibo()) {
|
||||
throw new AuthException(ResponseStatus.UNSUPPORTED);
|
||||
}
|
||||
@@ -48,7 +52,7 @@ public class AuthWeiboRequest implements AuthRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse login(AuthConfig config, String code) {
|
||||
public AuthResponse login(String code) {
|
||||
if (!AuthConfigChecker.isSupportedWeibo()) {
|
||||
return AuthResponse.builder()
|
||||
.code(ResponseStatus.UNSUPPORTED.getCode())
|
||||
|
||||
20
src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
Normal file
20
src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import lombok.Data;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
|
||||
/**
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0
|
||||
* @website https://www.zhyd.me
|
||||
* @date 2019/2/18 13:11
|
||||
* @since 1.8
|
||||
*/
|
||||
@Data
|
||||
public abstract class BaseAuthRequest {
|
||||
protected AuthConfig config;
|
||||
|
||||
public BaseAuthRequest(AuthConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user