优化

pull/31/head
smallbun 2023-08-19 13:55:03 +08:00
parent a61f6fe100
commit 3594e45586
5 changed files with 14 additions and 14 deletions

View File

@ -36,7 +36,7 @@ public enum IdentityProviderCategory implements BaseEnum {
* *
*/ */
social("social", "社交", Lists.newArrayList( social("social", "社交", Lists.newArrayList(
IdentityProviderType.QQ, IdentityProviderType.QQ_OAUTH,
IdentityProviderType.WECHAT_QR, IdentityProviderType.WECHAT_QR,
IdentityProviderType.GITEE_OAUTH, IdentityProviderType.GITEE_OAUTH,
IdentityProviderType.GITHUB_OAUTH)), IdentityProviderType.GITHUB_OAUTH)),

View File

@ -73,7 +73,7 @@ public final class IdentityProviderType {
/** /**
* QQ * QQ
*/ */
public static final IdentityProviderType QQ = new IdentityProviderType( public static final IdentityProviderType QQ_OAUTH = new IdentityProviderType(
"qq_oauth", "QQ认证", "通过QQ进行身份认证"); "qq_oauth", "QQ认证", "通过QQ进行身份认证");
/** /**

View File

@ -49,7 +49,7 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import static cn.topiam.employee.authentication.common.IdentityProviderType.QQ; import static cn.topiam.employee.authentication.common.IdentityProviderType.QQ_OAUTH;
import static cn.topiam.employee.authentication.common.constant.AuthenticationConstants.PROVIDER_CODE; import static cn.topiam.employee.authentication.common.constant.AuthenticationConstants.PROVIDER_CODE;
import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationConstants.URL_AUTHORIZE; import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationConstants.URL_AUTHORIZE;
import static cn.topiam.employee.authentication.qq.filter.QqOAuth2LoginAuthenticationFilter.getLoginUrl; import static cn.topiam.employee.authentication.qq.filter.QqOAuth2LoginAuthenticationFilter.getLoginUrl;
@ -70,7 +70,8 @@ public class QqOAuth2AuthorizationRequestRedirectFilter extends OncePerRequestFi
* AntPathRequestMatcher * AntPathRequestMatcher
*/ */
public static final AntPathRequestMatcher QQ_REQUEST_MATCHER = new AntPathRequestMatcher( public static final AntPathRequestMatcher QQ_REQUEST_MATCHER = new AntPathRequestMatcher(
QQ.getAuthorizationPathPrefix() + "/" + "{" + PROVIDER_CODE + "}", HttpMethod.GET.name()); QQ_OAUTH.getAuthorizationPathPrefix() + "/" + "{" + PROVIDER_CODE + "}",
HttpMethod.GET.name());
/** /**
* *

View File

@ -54,7 +54,7 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import static com.nimbusds.oauth2.sdk.GrantType.AUTHORIZATION_CODE; import static com.nimbusds.oauth2.sdk.GrantType.AUTHORIZATION_CODE;
import static cn.topiam.employee.authentication.common.IdentityProviderType.QQ; import static cn.topiam.employee.authentication.common.IdentityProviderType.QQ_OAUTH;
import static cn.topiam.employee.authentication.common.constant.AuthenticationConstants.*; import static cn.topiam.employee.authentication.common.constant.AuthenticationConstants.*;
import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationConstants.URL_GET_ACCESS_TOKEN; import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationConstants.URL_GET_ACCESS_TOKEN;
import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationConstants.URL_GET_OPEN_ID; import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationConstants.URL_GET_OPEN_ID;
@ -68,9 +68,8 @@ import static cn.topiam.employee.authentication.qq.constant.QqAuthenticationCons
@SuppressWarnings({ "AlibabaClassNamingShouldBeCamel", "DuplicatedCode" }) @SuppressWarnings({ "AlibabaClassNamingShouldBeCamel", "DuplicatedCode" })
public class QqOAuth2LoginAuthenticationFilter extends AbstractIdpAuthenticationProcessingFilter { public class QqOAuth2LoginAuthenticationFilter extends AbstractIdpAuthenticationProcessingFilter {
final String ERROR_CODE = "error"; final String ERROR_CODE = "error";
public final static String DEFAULT_FILTER_PROCESSES_URI = QQ.getLoginPathPrefix() public final static String DEFAULT_FILTER_PROCESSES_URI = QQ_OAUTH
+ "/" + "{" .getLoginPathPrefix() + "/" + "{" + PROVIDER_CODE + "}";
+ PROVIDER_CODE + "}";
public static final AntPathRequestMatcher REQUEST_MATCHER = new AntPathRequestMatcher( public static final AntPathRequestMatcher REQUEST_MATCHER = new AntPathRequestMatcher(
DEFAULT_FILTER_PROCESSES_URI, HttpMethod.GET.name()); DEFAULT_FILTER_PROCESSES_URI, HttpMethod.GET.name());
@ -156,14 +155,14 @@ public class QqOAuth2LoginAuthenticationFilter extends AbstractIdpAuthentication
} }
// 返回 // 返回
String openId = result.getString(OidcScopes.OPENID); String openId = result.getString(OidcScopes.OPENID);
IdpUserDetails idpUserDetails = IdpUserDetails.builder().openId(openId).providerType(QQ) IdpUserDetails idpUserDetails = IdpUserDetails.builder().openId(openId)
.providerCode(providerCode).providerId(providerId).build(); .providerType(QQ_OAUTH).providerCode(providerCode).providerId(providerId).build();
return attemptAuthentication(request, response, idpUserDetails); return attemptAuthentication(request, response, idpUserDetails);
} }
public static String getLoginUrl(String providerId) { public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + "/" + QQ.getLoginPathPrefix() + "/" String url = ServerHelp.getPortalPublicBaseUrl() + "/" + QQ_OAUTH.getLoginPathPrefix() + "/"
+ providerId; + providerId;
return HttpUrlUtils.format(url); return HttpUrlUtils.format(url);
} }

View File

@ -256,7 +256,7 @@ public interface IdentityProviderConverter {
} else if (type.equals(WECHAT_WORK_QR.value())) { } else if (type.equals(WECHAT_WORK_QR.value())) {
identityProviderConfig = config.to(WeChatWorkIdpScanCodeConfig.class); identityProviderConfig = config.to(WeChatWorkIdpScanCodeConfig.class);
//QQ认证 //QQ认证
} else if (type.equals(QQ.value())) { } else if (type.equals(QQ_OAUTH.value())) {
identityProviderConfig = config.to(QqIdpOauthConfig.class); identityProviderConfig = config.to(QqIdpOauthConfig.class);
//飞书认证 //飞书认证
} else if (type.equals(FEISHU_OAUTH.value())) { } else if (type.equals(FEISHU_OAUTH.value())) {
@ -304,8 +304,8 @@ public interface IdentityProviderConverter {
if (WECHAT_WORK_QR.value().equals(type)) { if (WECHAT_WORK_QR.value().equals(type)) {
return WECHAT_WORK_QR; return WECHAT_WORK_QR;
} }
if (QQ.value().equals(type)) { if (QQ_OAUTH.value().equals(type)) {
return QQ; return QQ_OAUTH;
} }
if (LDAP.value().equals(type)) { if (LDAP.value().equals(type)) {
return LDAP; return LDAP;