优化身份提供商

pull/82/head^2
awenes 8 months ago
parent 69fd16f7d5
commit 4214f08ee4

@ -49,7 +49,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.trace.TraceUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@ -159,7 +159,7 @@ public class AlipayLoginAuthenticationFilter extends AbstractIdpAuthenticationPr
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + ALIPAY_OAUTH.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -55,7 +55,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.trace.TraceUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -208,7 +208,7 @@ public class DingtalkOauthAuthenticationFilter extends AbstractIdpAuthentication
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + DINGTALK_OAUTH.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -60,7 +60,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.trace.TraceUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -243,7 +243,7 @@ public class DingtalkScanCodeAuthenticationFilter extends
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + DINGTALK_QR.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -46,7 +46,7 @@ import cn.topiam.employee.common.entity.authn.IdentityProviderEntity;
import cn.topiam.employee.common.repository.authentication.IdentityProviderRepository;
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.util.HttpClientUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -149,7 +149,7 @@ public class FeiShuLoginAuthenticationFilter extends AbstractIdpAuthenticationPr
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + FEISHU_OAUTH.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -45,7 +45,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.util.HttpClientUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -170,7 +170,7 @@ public class GiteeLoginAuthenticationFilter extends AbstractIdpAuthenticationPro
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + GITEE_OAUTH.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -48,7 +48,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.trace.TraceUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -174,7 +174,7 @@ public class GithubOAuth2LoginAuthenticationFilter extends
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + "/" + GITHUB_OAUTH.getLoginPathPrefix()
+ "/" + providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -17,6 +17,8 @@
*/
package cn.topiam.employee.authentication.otp.mail.filter;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -86,11 +88,11 @@ public class MailOtpAuthenticationFilter extends AbstractAuthenticationProcessin
"Authentication method not supported: " + request.getMethod());
}
// 获取手机号/邮箱
String recipient = StringUtils.defaultString(obtainUsername(request), "").trim();
String recipient = Objects.toString(obtainUsername(request), "").trim();
if (StringUtils.isBlank(recipient)) {
throw new MailNotExistException();
}
String code = StringUtils.defaultString(obtainCode(request), "").trim();
String code = Objects.toString(obtainCode(request), "").trim();
if (StringUtils.isBlank(code)) {
throw new CaptchaNotExistException();
}

@ -48,7 +48,7 @@ import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.trace.TraceUtils;
import cn.topiam.employee.support.util.HttpClientUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -164,7 +164,7 @@ public class QqOAuth2LoginAuthenticationFilter extends AbstractIdpAuthentication
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + "/" + QQ_OAUTH.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -17,6 +17,8 @@
*/
package cn.topiam.employee.authentication.otp.sms.filter;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -88,11 +90,11 @@ public class SmsOtpAuthenticationFilter extends AbstractAuthenticationProcessing
"Authentication method not supported: " + request.getMethod());
}
// 获取手机号/邮箱
String recipient = StringUtils.defaultString(obtainUsername(request), "").trim();
String recipient = Objects.toString(obtainUsername(request), "").trim();
if (StringUtils.isBlank(recipient)) {
throw new PhoneNotExistException();
}
String code = StringUtils.defaultString(obtainCode(request), "").trim();
String code = Objects.toString(obtainCode(request), "").trim();
if (StringUtils.isBlank(code)) {
throw new CaptchaNotExistException();
}

@ -46,7 +46,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.util.HttpClientUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -160,7 +160,7 @@ public class WeChatScanCodeLoginAuthenticationFilter extends
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + WECHAT_QR.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}
public static RequestMatcher getRequestMatcher() {

@ -50,7 +50,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos
import cn.topiam.employee.core.help.ServerHelp;
import cn.topiam.employee.support.trace.TraceUtils;
import cn.topiam.employee.support.util.HttpClientUtils;
import cn.topiam.employee.support.util.HttpUrlUtils;
import cn.topiam.employee.support.util.UrlUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -146,8 +146,7 @@ public class WeChatWorkScanCodeLoginAuthenticationFilter extends
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString());
}
// 返回
String userId = StringUtils.defaultString(result.getString("UserId"),
result.getString("OpenId"));
String userId = Objects.toString(result.getString("UserId"), result.getString("OpenId"));
IdpUserDetails idpUserDetails = IdpUserDetails.builder().openId(userId)
.providerType(WECHAT_WORK_QR).providerCode(providerCode).providerId(providerId).build();
return attemptAuthentication(request, response, idpUserDetails);
@ -192,7 +191,7 @@ public class WeChatWorkScanCodeLoginAuthenticationFilter extends
public static String getLoginUrl(String providerId) {
String url = ServerHelp.getPortalPublicBaseUrl() + WECHAT_WORK_QR.getLoginPathPrefix() + "/"
+ providerId;
return HttpUrlUtils.format(url);
return UrlUtils.format(url);
}

Loading…
Cancel
Save