mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-15 04:52:09 +08:00
split maxkey-authentication-sms
This commit is contained in:
@@ -31,7 +31,7 @@ import org.maxkey.constants.ConstsLoginType;
|
||||
import org.maxkey.constants.ConstsStatus;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||
import org.maxkey.password.onetimepwd.OtpAuthnService;
|
||||
import org.maxkey.password.onetimepwd.MailOtpAuthnService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
@@ -67,7 +67,7 @@ public abstract class AbstractAuthenticationProvider {
|
||||
|
||||
protected AbstractOtpAuthn tfaOtpAuthn;
|
||||
|
||||
protected OtpAuthnService otpAuthnService;
|
||||
protected MailOtpAuthnService otpAuthnService;
|
||||
|
||||
protected SessionManager sessionManager;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstsLoginType;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||
import org.maxkey.password.onetimepwd.OtpAuthnService;
|
||||
import org.maxkey.password.sms.SmsOtpAuthnService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
@@ -46,6 +46,8 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
|
||||
private static final Logger _logger =
|
||||
LoggerFactory.getLogger(MobileAuthenticationProvider.class);
|
||||
|
||||
SmsOtpAuthnService smsOtpAuthnService;
|
||||
|
||||
public String getProviderName() {
|
||||
return "mobile" + PROVIDER_SUFFIX;
|
||||
}
|
||||
@@ -59,11 +61,11 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
|
||||
public MobileAuthenticationProvider(
|
||||
AbstractAuthenticationRealm authenticationRealm,
|
||||
ApplicationConfig applicationConfig,
|
||||
OtpAuthnService otpAuthnService,
|
||||
SmsOtpAuthnService smsOtpAuthnService,
|
||||
SessionManager sessionManager) {
|
||||
this.authenticationRealm = authenticationRealm;
|
||||
this.applicationConfig = applicationConfig;
|
||||
this.otpAuthnService = otpAuthnService;
|
||||
this.smsOtpAuthnService = smsOtpAuthnService;
|
||||
this.sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
@@ -136,7 +138,7 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
|
||||
UserInfo validUserInfo = new UserInfo();
|
||||
validUserInfo.setUsername(userInfo.getUsername());
|
||||
validUserInfo.setId(userInfo.getId());
|
||||
AbstractOtpAuthn smsOtpAuthn = otpAuthnService.getByInstId(userInfo.getInstId());
|
||||
AbstractOtpAuthn smsOtpAuthn = smsOtpAuthnService.getByInstId(userInfo.getInstId());
|
||||
if (password == null || !smsOtpAuthn.validate(validUserInfo, password)) {
|
||||
String message = WebContext.getI18nValue("login.error.captcha");
|
||||
_logger.debug("login captcha valid error.");
|
||||
|
||||
@@ -28,15 +28,10 @@ import org.maxkey.authn.session.SessionManager;
|
||||
import org.maxkey.authn.support.rememberme.AbstractRemeberMeManager;
|
||||
import org.maxkey.authn.support.rememberme.JdbcRemeberMeManager;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstsPersistence;
|
||||
import org.maxkey.password.onetimepwd.OtpAuthnService;
|
||||
import org.maxkey.password.onetimepwd.token.RedisOtpTokenStore;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.maxkey.password.sms.SmsOtpAuthnService;
|
||||
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||
import org.maxkey.persistence.repository.LoginRepository;
|
||||
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||
import org.maxkey.persistence.service.EmailSendersService;
|
||||
import org.maxkey.persistence.service.SmsProviderService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -86,14 +81,14 @@ public class AuthnProviderAutoConfiguration implements InitializingBean {
|
||||
public AbstractAuthenticationProvider mobileAuthenticationProvider(
|
||||
AbstractAuthenticationRealm authenticationRealm,
|
||||
ApplicationConfig applicationConfig,
|
||||
OtpAuthnService otpAuthnService,
|
||||
SmsOtpAuthnService smsAuthnService,
|
||||
SessionManager sessionManager
|
||||
) {
|
||||
_logger.debug("init Mobile authentication Provider .");
|
||||
return new MobileAuthenticationProvider(
|
||||
authenticationRealm,
|
||||
applicationConfig,
|
||||
otpAuthnService,
|
||||
smsAuthnService,
|
||||
sessionManager
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user