优化

pull/31/head
smallbun 2023-08-19 13:49:19 +08:00
parent 35d9df8b0d
commit a61f6fe100
5 changed files with 17 additions and 18 deletions

View File

@ -35,12 +35,11 @@ public enum IdentityProviderCategory implements BaseEnum {
/**
*
*/
social("social", "社交",
Lists.newArrayList(
social("social", "社交", Lists.newArrayList(
IdentityProviderType.QQ,
IdentityProviderType.WECHAT_QR,
IdentityProviderType.GITHUB,
IdentityProviderType.GITHUB)),
IdentityProviderType.GITEE_OAUTH,
IdentityProviderType.GITHUB_OAUTH)),
/**
*
*/

View File

@ -103,7 +103,7 @@ public final class IdentityProviderType {
/**
* GITHUB
*/
public static final IdentityProviderType GITHUB = new IdentityProviderType(
public static final IdentityProviderType GITHUB_OAUTH = new IdentityProviderType(
"github_oauth", "GITHUB认证", "通过GITHUB进行身份认证");
private final String value;

View File

@ -49,7 +49,7 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import static cn.topiam.employee.authentication.common.IdentityProviderType.GITHUB;
import static cn.topiam.employee.authentication.common.IdentityProviderType.GITHUB_OAUTH;
import static cn.topiam.employee.authentication.common.constant.AuthenticationConstants.PROVIDER_CODE;
import static cn.topiam.employee.authentication.github.constant.GithubAuthenticationConstants.URL_AUTHORIZE;
import static cn.topiam.employee.authentication.github.filter.GithubOAuth2LoginAuthenticationFilter.getLoginUrl;
@ -70,7 +70,7 @@ public class GithubOAuth2AuthorizationRequestRedirectFilter extends OncePerReque
* AntPathRequestMatcher
*/
public static final AntPathRequestMatcher GITHUB_REQUEST_MATCHER = new AntPathRequestMatcher(
GITHUB.getAuthorizationPathPrefix() + "/" + "{" + PROVIDER_CODE + "}",
GITHUB_OAUTH.getAuthorizationPathPrefix() + "/" + "{" + PROVIDER_CODE + "}",
HttpMethod.GET.name());
/**

View File

@ -52,7 +52,7 @@ import cn.topiam.employee.support.util.HttpUrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import static cn.topiam.employee.authentication.common.IdentityProviderType.GITHUB;
import static cn.topiam.employee.authentication.common.IdentityProviderType.GITHUB_OAUTH;
import static cn.topiam.employee.authentication.common.constant.AuthenticationConstants.*;
import static cn.topiam.employee.authentication.github.constant.GithubAuthenticationConstants.*;
@ -66,7 +66,7 @@ import static cn.topiam.employee.authentication.github.constant.GithubAuthentica
public class GithubOAuth2LoginAuthenticationFilter extends
AbstractIdpAuthenticationProcessingFilter {
final String ERROR_CODE = "error";
public final static String DEFAULT_FILTER_PROCESSES_URI = GITHUB
public final static String DEFAULT_FILTER_PROCESSES_URI = GITHUB_OAUTH
.getLoginPathPrefix() + "/" + "{" + PROVIDER_CODE + "}";
public static final AntPathRequestMatcher REQUEST_MATCHER = new AntPathRequestMatcher(
DEFAULT_FILTER_PROCESSES_URI, HttpMethod.GET.name());
@ -150,8 +150,8 @@ public class GithubOAuth2LoginAuthenticationFilter extends
}
// 返回
String id = result.getString("id");
IdpUserDetails idpUserDetails = IdpUserDetails.builder().openId(id).providerType(GITHUB)
.providerCode(providerCode).providerId(providerId).build();
IdpUserDetails idpUserDetails = IdpUserDetails.builder().openId(id)
.providerType(GITHUB_OAUTH).providerCode(providerCode).providerId(providerId).build();
return attemptAuthentication(request, response, idpUserDetails);
}
@ -172,8 +172,8 @@ public class GithubOAuth2LoginAuthenticationFilter extends
}
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + "/" + GITHUB.getLoginPathPrefix() + "/"
+ providerId;
String url = ServerHelp.getPortalPublicBaseUrl() + "/" + GITHUB_OAUTH.getLoginPathPrefix()
+ "/" + providerId;
return HttpUrlUtils.format(url);
}

View File

@ -262,7 +262,7 @@ public interface IdentityProviderConverter {
} else if (type.equals(FEISHU_OAUTH.value())) {
identityProviderConfig = config.to(FeiShuIdpScanCodeConfig.class);
//GITHUB认证
} else if (type.equals(GITHUB.value())) {
} else if (type.equals(GITHUB_OAUTH.value())) {
identityProviderConfig = config.to(GithubIdpOauthConfig.class);
}
//Gitee
@ -319,8 +319,8 @@ public interface IdentityProviderConverter {
if (WECHAT_WEB_PAGE.value().equals(type)) {
return WECHAT_WEB_PAGE;
}
if (GITHUB.value().equals(type)) {
return GITHUB;
if (GITHUB_OAUTH.value().equals(type)) {
return GITHUB_OAUTH;
}
if (GITEE_OAUTH.value().equals(type)) {
return GITEE_OAUTH;