diff --git a/build.gradle b/build.gradle index 87e5e13cf..6b9b4cc4a 100644 --- a/build.gradle +++ b/build.gradle @@ -47,13 +47,13 @@ allprojects { compileJava.options.encoding = 'UTF-8' eclipse { - /*第一次时请注释这段eclipse设置,可能报错 + /*第一次时请注释这段eclipse设置,可能报错*/ jdt { File f = file('.settings/org.eclipse.core.resources.prefs') f.write('eclipse.preferences.version=1\n') f.append('encoding/=UTF-8') //use UTF-8 } - */ + /* wtp { diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java index 51b5ded88..c4d20348b 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java @@ -52,7 +52,7 @@ public abstract class AbstractAuthenticationProvider { protected AbstractAuthenticationRealm authenticationRealm; - protected AbstractOtpAuthn tfaOptAuthn; + protected AbstractOtpAuthn tfaOtpAuthn; protected AbstractRemeberMeService remeberMeService; @@ -227,7 +227,7 @@ public abstract class AbstractAuthenticationProvider { validUserInfo.setSharedSecret(sharedSecret); validUserInfo.setSharedCounter(userInfo.getSharedCounter()); validUserInfo.setId(userInfo.getId()); - if (otpCaptcha == null || !tfaOptAuthn.validate(validUserInfo, otpCaptcha)) { + if (otpCaptcha == null || !tfaOtpAuthn.validate(validUserInfo, otpCaptcha)) { String message = WebContext.getI18nValue("login.error.captcha"); _logger.debug("login captcha valid error."); throw new BadCredentialsException(message); @@ -320,8 +320,8 @@ public abstract class AbstractAuthenticationProvider { this.authenticationRealm = authenticationRealm; } - public void setTfaOptAuthn(AbstractOtpAuthn tfaOptAuthn) { - this.tfaOptAuthn = tfaOptAuthn; + public void setTfaOtpAuthn(AbstractOtpAuthn tfaOtpAuthn) { + this.tfaOtpAuthn = tfaOtpAuthn; } public void setRemeberMeService(AbstractRemeberMeService remeberMeService) { diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/RealmAuthenticationProvider.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/RealmAuthenticationProvider.java index d06e72513..cd7c18e04 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/RealmAuthenticationProvider.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/RealmAuthenticationProvider.java @@ -61,12 +61,12 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider public RealmAuthenticationProvider( AbstractAuthenticationRealm authenticationRealm, ApplicationConfig applicationConfig, - AbstractOtpAuthn tfaOptAuthn, + AbstractOtpAuthn tfaOtpAuthn, AbstractRemeberMeService remeberMeService, OnlineTicketServices onlineTicketServices) { this.authenticationRealm = authenticationRealm; this.applicationConfig = applicationConfig; - this.tfaOptAuthn = tfaOptAuthn; + this.tfaOtpAuthn = tfaOtpAuthn; this.remeberMeService = remeberMeService; this.onlineTicketServices = onlineTicketServices; } diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java index 85087337d..5a3fcdbd9 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java @@ -80,7 +80,7 @@ public class AuthenticationAutoConfiguration implements InitializingBean { public AbstractAuthenticationProvider authenticationProvider( AbstractAuthenticationRealm authenticationRealm, ApplicationConfig applicationConfig, - AbstractOtpAuthn tfaOptAuthn, + AbstractOtpAuthn tfaOtpAuthn, AbstractRemeberMeService remeberMeService, OnlineTicketServices onlineTicketServices ) { @@ -88,7 +88,7 @@ public class AuthenticationAutoConfiguration implements InitializingBean { return new RealmAuthenticationProvider( authenticationRealm, applicationConfig, - tfaOptAuthn, + tfaOtpAuthn, remeberMeService, onlineTicketServices ); diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java index 1e5a40304..2312b36b7 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java @@ -176,49 +176,49 @@ public class MaxKeyConfig implements InitializingBean { return authenticationRealm; } - @Bean(name = "tfaOptAuthn") + @Bean(name = "tfaOtpAuthn") public TimeBasedOtpAuthn tfaOptAuthn() { - TimeBasedOtpAuthn tfaOptAuthn = new TimeBasedOtpAuthn(); + TimeBasedOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn(); _logger.debug("TimeBasedOtpAuthn inited."); - return tfaOptAuthn; + return tfaOtpAuthn; } - //default tfaOptAuthn - @Bean(name = "tfaOptAuthn") + //default tfaOtpAuthn + @Bean(name = "tfaOtpAuthn") public AbstractOtpAuthn tfaOptAuthn( @Value("${config.login.mfa.type}")String mfaType, @Value("${config.server.persistence}") int persistence, - MailOtpAuthn tfaMailOptAuthn, + MailOtpAuthn tfaMailOtpAuthn, RedisConnectionFactory redisConnFactory) { - AbstractOtpAuthn tfaOptAuthn = null; + AbstractOtpAuthn tfaOtpAuthn = null; if(mfaType.equalsIgnoreCase("SmsOtpAuthnAliyun")) { - tfaOptAuthn = new SmsOtpAuthnAliyun(); + tfaOtpAuthn = new SmsOtpAuthnAliyun(); _logger.debug("SmsOtpAuthnAliyun inited."); }else if(mfaType.equalsIgnoreCase("SmsOtpAuthnTencentCloud")) { - tfaOptAuthn = new SmsOtpAuthnTencentCloud(); + tfaOtpAuthn = new SmsOtpAuthnTencentCloud(); _logger.debug("SmsOtpAuthnTencentCloud inited."); }else if(mfaType.equalsIgnoreCase("SmsOtpAuthnYunxin")) { - tfaOptAuthn = new SmsOtpAuthnYunxin(); + tfaOtpAuthn = new SmsOtpAuthnYunxin(); _logger.debug("SmsOtpAuthnYunxin inited."); }else if(mfaType.equalsIgnoreCase("MailOtpAuthn")) { - tfaOptAuthn = tfaMailOptAuthn; + tfaOtpAuthn = tfaMailOtpAuthn; _logger.debug("MailOtpAuthn inited."); }else { - tfaOptAuthn = new TimeBasedOtpAuthn(); + tfaOtpAuthn = new TimeBasedOtpAuthn(); _logger.debug("TimeBasedOtpAuthn inited."); } if (persistence == ConstantsPersistence.REDIS) { RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory); - tfaOptAuthn.setOptTokenStore(redisOptTokenStore); + tfaOtpAuthn.setOptTokenStore(redisOptTokenStore); } - tfaOptAuthn.initPropertys(); - return tfaOptAuthn; + tfaOtpAuthn.initPropertys(); + return tfaOtpAuthn; } - @Bean(name = "tfaMailOptAuthn") + @Bean(name = "tfaMailOtpAuthn") public MailOtpAuthn mailOtpAuthn( @Value("${spring.mail.properties.mailotp.message.subject}") String messageSubject, @@ -228,11 +228,11 @@ public class MaxKeyConfig implements InitializingBean { MailOtpAuthn mailOtpAuthn = new MailOtpAuthn(); mailOtpAuthn.setSubject(messageSubject); mailOtpAuthn.setMessageTemplate(messageTemplate); - _logger.debug("tfaMailOptAuthn inited."); + _logger.debug("tfaMailOtpAuthn inited."); return mailOtpAuthn; } - @Bean(name = "tfaMobileOptAuthn") + @Bean(name = "tfaMobileOtpAuthn") public SmsOtpAuthn smsOtpAuthn( @Value("${config.otp.sms}")String optSmsProvider, @Value("${config.server.persistence}") int persistence, diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java b/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java index 2adc9b170..c7886cfca 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java @@ -62,12 +62,12 @@ public class ForgotPasswordContorller { private UserInfoService userInfoService; @Autowired - @Qualifier("tfaMailOptAuthn") - protected AbstractOtpAuthn tfaMailOptAuthn; + @Qualifier("tfaMailOtpAuthn") + protected AbstractOtpAuthn tfaMailOtpAuthn; @Autowired - @Qualifier("tfaMobileOptAuthn") - protected AbstractOtpAuthn tfaMobileOptAuthn; + @Qualifier("tfaMobileOtpAuthn") + protected AbstractOtpAuthn tfaMobileOtpAuthn; @RequestMapping(value = { "/forward" }) @@ -89,10 +89,10 @@ public class ForgotPasswordContorller { Matcher matcher = emailRegex.matcher(emailMobile); if (matcher.matches() && null != userInfo) { - tfaMailOptAuthn.produce(userInfo); + tfaMailOtpAuthn.produce(userInfo); forgotType = ForgotType.EMAIL; }else if (null != userInfo) { - tfaMobileOptAuthn.produce(userInfo); + tfaMobileOtpAuthn.produce(userInfo); forgotType = ForgotType.MOBILE; } @@ -126,8 +126,8 @@ public class ForgotPasswordContorller { userInfo.setUsername(username); userInfo.setPassword(password); userInfo.setDecipherable(password); - if ((forgotType == ForgotType.EMAIL && tfaMailOptAuthn.validate(userInfo, captcha)) || - (forgotType == ForgotType.MOBILE && tfaMobileOptAuthn.validate(userInfo, captcha)) + if ((forgotType == ForgotType.EMAIL && tfaMailOtpAuthn.validate(userInfo, captcha)) || + (forgotType == ForgotType.MOBILE && tfaMobileOtpAuthn.validate(userInfo, captcha)) ) { userInfoService.changePassword(userInfo); modelAndView.addObject("passwordResetResult", PasswordResetResult.SUCCESS); diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java b/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java index a8f6f5553..5380d3216 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java @@ -92,8 +92,8 @@ public class LoginEndpoint { AbstractAuthenticationProvider authenticationProvider ; @Autowired - @Qualifier("tfaOptAuthn") - protected AbstractOtpAuthn tfaOptAuthn; + @Qualifier("tfaOtpAuthn") + protected AbstractOtpAuthn tfaOtpAuthn; /* @Autowired @@ -151,8 +151,8 @@ public class LoginEndpoint { modelAndView.addObject("isKerberos", applicationConfig.getLoginConfig().isKerberos()); modelAndView.addObject("isMfa", applicationConfig.getLoginConfig().isMfa()); if(applicationConfig.getLoginConfig().isMfa()) { - modelAndView.addObject("optType", tfaOptAuthn.getOtpType()); - modelAndView.addObject("optInterval", tfaOptAuthn.getInterval()); + modelAndView.addObject("otpType", tfaOtpAuthn.getOtpType()); + modelAndView.addObject("otpInterval", tfaOtpAuthn.getInterval()); } if( applicationConfig.getLoginConfig().isKerberos()){ @@ -218,7 +218,7 @@ public class LoginEndpoint { userInfo.setUsername(username); UserInfo queryUserInfo=userInfoService.loadByUsername(username);//(userInfo); if(queryUserInfo!=null) { - tfaOptAuthn.produce(queryUserInfo); + tfaOtpAuthn.produce(queryUserInfo); return "ok"; } diff --git a/maxkey-web-maxkey/src/main/resources/templates/views/login.ftl b/maxkey-web-maxkey/src/main/resources/templates/views/login.ftl index abfe189a9..5f36d3793 100644 --- a/maxkey-web-maxkey/src/main/resources/templates/views/login.ftl +++ b/maxkey-web-maxkey/src/main/resources/templates/views/login.ftl @@ -60,7 +60,7 @@ strTime+=(seconds<10?"0"+seconds:seconds); } - <#if true==isMfa && "TOPT"==optType> + <#if true==isMfa && "TOPT"==otpType> function currentTime(){ seconds++; if(seconds>59){ @@ -85,10 +85,10 @@ <#--timeBase Token Interval default is 30s--> var timeBaseCount; function getTimeBaseCount(){ - if(seconds<${optInterval}){ - timeBaseCount=${optInterval}-seconds; + if(seconds<${otpInterval}){ + timeBaseCount=${otpInterval}-seconds; }else{ - timeBaseCount=${optInterval}-(seconds-${optInterval}); + timeBaseCount=${otpInterval}-(seconds-${otpInterval}); } $("#tfa_j_otp_captcha_button").val("<@locale code="login.text.login.twofactor.validTime"/>("+timeBaseCount+")<@locale code="login.text.login.twofactor.validTime.unit"/>"); }; @@ -125,7 +125,7 @@ }; $(function(){ - <#if true==isMfa && "TOPT"==optType> + <#if true==isMfa && "TOPT"==otpType> setInterval("currentTime()", 1000); <#--on captcha image click ,new a captcha code--> @@ -298,7 +298,7 @@ <#if true==isMfa > - <#if "TOPT"==optType > + <#if "TOPT"==otpType > <@locale code="login.text.currenttime"/>: