mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-16 13:30:43 +08:00
separate common
This commit is contained in:
@@ -29,15 +29,15 @@ import org.maxkey.authn.support.kerberos.KerberosProxy;
|
||||
import org.maxkey.authn.support.kerberos.RemoteKerberosService;
|
||||
import org.maxkey.constants.ConstantsPersistence;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
||||
import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
|
||||
import org.maxkey.crypto.password.opt.impl.MailOtpAuthn;
|
||||
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
|
||||
import org.maxkey.crypto.password.opt.impl.TimeBasedOtpAuthn;
|
||||
import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnAliyun;
|
||||
import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnTencentCloud;
|
||||
import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnYunxin;
|
||||
import org.maxkey.crypto.password.opt.token.RedisOptTokenStore;
|
||||
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||
import org.maxkey.crypto.password.otp.algorithm.KeyUriFormat;
|
||||
import org.maxkey.crypto.password.otp.impl.MailOtpAuthn;
|
||||
import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
|
||||
import org.maxkey.crypto.password.otp.impl.TimeBasedOtpAuthn;
|
||||
import org.maxkey.crypto.password.otp.impl.sms.SmsOtpAuthnAliyun;
|
||||
import org.maxkey.crypto.password.otp.impl.sms.SmsOtpAuthnTencentCloud;
|
||||
import org.maxkey.crypto.password.otp.impl.sms.SmsOtpAuthnYunxin;
|
||||
import org.maxkey.crypto.password.otp.token.RedisOtpTokenStore;
|
||||
import org.maxkey.persistence.ldap.ActiveDirectoryUtils;
|
||||
import org.maxkey.persistence.ldap.LdapUtils;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
@@ -156,15 +156,22 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
return authenticationRealm;
|
||||
}
|
||||
|
||||
@Bean(name = "tfaOptAuthn")
|
||||
public TimeBasedOtpAuthn tfaOptAuthn() {
|
||||
TimeBasedOtpAuthn tfaOptAuthn = new TimeBasedOtpAuthn();
|
||||
_logger.debug("TimeBasedOtpAuthn inited.");
|
||||
return tfaOptAuthn;
|
||||
}
|
||||
|
||||
//default tfaOptAuthn
|
||||
@Bean(name = "tfaOptAuthn")
|
||||
public AbstractOptAuthn tfaOptAuthn(
|
||||
public AbstractOtpAuthn tfaOptAuthn(
|
||||
@Value("${config.login.mfa.type}")String mfaType,
|
||||
@Value("${config.server.persistence}") int persistence,
|
||||
MailOtpAuthn tfaMailOptAuthn,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
|
||||
AbstractOptAuthn tfaOptAuthn = null;
|
||||
AbstractOtpAuthn tfaOptAuthn = null;
|
||||
if(mfaType.equalsIgnoreCase("SmsOtpAuthnAliyun")) {
|
||||
tfaOptAuthn = new SmsOtpAuthnAliyun();
|
||||
_logger.debug("SmsOtpAuthnAliyun inited.");
|
||||
@@ -183,7 +190,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
}
|
||||
|
||||
if (persistence == ConstantsPersistence.REDIS) {
|
||||
RedisOptTokenStore redisOptTokenStore = new RedisOptTokenStore(redisConnFactory);
|
||||
RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory);
|
||||
tfaOptAuthn.setOptTokenStore(redisOptTokenStore);
|
||||
}
|
||||
|
||||
@@ -219,7 +226,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
smsOtpAuthn = new SmsOtpAuthnYunxin();
|
||||
}
|
||||
if (persistence == ConstantsPersistence.REDIS) {
|
||||
RedisOptTokenStore redisOptTokenStore = new RedisOptTokenStore(redisConnFactory);
|
||||
RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory);
|
||||
smsOtpAuthn.setOptTokenStore(redisOptTokenStore);
|
||||
}
|
||||
smsOtpAuthn.initPropertys();
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.maxkey.web.contorller;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
||||
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
@@ -63,11 +63,11 @@ public class ForgotPasswordContorller {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("tfaMailOptAuthn")
|
||||
protected AbstractOptAuthn tfaMailOptAuthn;
|
||||
protected AbstractOtpAuthn tfaMailOptAuthn;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("tfaMobileOptAuthn")
|
||||
protected AbstractOptAuthn tfaMobileOptAuthn;
|
||||
protected AbstractOtpAuthn tfaMobileOptAuthn;
|
||||
|
||||
|
||||
@RequestMapping(value = { "/forward" })
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.UUID;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.maxkey.crypto.Base32Utils;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
|
||||
import org.maxkey.crypto.password.opt.algorithm.OtpSecret;
|
||||
import org.maxkey.crypto.password.otp.algorithm.KeyUriFormat;
|
||||
import org.maxkey.crypto.password.otp.algorithm.OtpSecret;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.util.RQCodeUtils;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService
|
||||
import org.maxkey.authn.support.wsfederation.WsFederationConstants;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
||||
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.util.StringUtils;
|
||||
@@ -93,7 +93,7 @@ public class LoginEndpoint {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("tfaOptAuthn")
|
||||
protected AbstractOptAuthn tfaOptAuthn;
|
||||
protected AbstractOtpAuthn tfaOptAuthn;
|
||||
|
||||
/*
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user