登录验证码配置优化
This commit is contained in:
@@ -26,6 +26,9 @@ public class LoginConfig {
|
||||
@Value("${maxkey.login.captcha}")
|
||||
boolean captcha;
|
||||
|
||||
@Value("${maxkey.login.captcha.type}")
|
||||
String captchaType;
|
||||
|
||||
@Value("${maxkey.login.mfa}")
|
||||
boolean mfa;
|
||||
|
||||
@@ -108,6 +111,14 @@ public class LoginConfig {
|
||||
this.casService = casService;
|
||||
}
|
||||
|
||||
public String getCaptchaType() {
|
||||
return captchaType;
|
||||
}
|
||||
|
||||
public void setCaptchaType(String captchaType) {
|
||||
this.captchaType = captchaType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -67,6 +67,7 @@ export class UserLoginComponent implements OnInit, OnDestroy {
|
||||
type = 0;
|
||||
loading = false;
|
||||
state = '';
|
||||
captchaType = '';
|
||||
imageCaptcha = '';
|
||||
passwordVisible = false;
|
||||
|
||||
@@ -96,8 +97,9 @@ export class UserLoginComponent implements OnInit, OnDestroy {
|
||||
// 清空路由复用信息
|
||||
//console.log(res.data);
|
||||
this.state = res.data.state;
|
||||
this.captchaType = res.data.captcha;
|
||||
//init image captcha
|
||||
this.imageCaptchaService.captcha({ state: this.state }).subscribe(res => {
|
||||
this.imageCaptchaService.captcha({ state: this.state, captcha: this.captchaType }).subscribe(res => {
|
||||
this.imageCaptcha = res.data.image;
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
@@ -110,7 +112,7 @@ export class UserLoginComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
getImageCaptcha(): void {
|
||||
this.imageCaptchaService.captcha({ state: this.state }).subscribe(res => {
|
||||
this.imageCaptchaService.captcha({ state: this.state, captcha: this.captchaType }).subscribe(res => {
|
||||
this.imageCaptcha = res.data.image;
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
|
||||
@@ -142,7 +142,9 @@ public class LoginEntryPoint {
|
||||
Institutions inst = (Institutions)WebContext.getAttribute(WebConstants.CURRENT_INST);
|
||||
model.put("inst", inst);
|
||||
if(applicationConfig.getLoginConfig().isCaptcha()) {
|
||||
model.put("captcha", "true");
|
||||
model.put("captcha", applicationConfig.getLoginConfig().getCaptchaType());
|
||||
}else {
|
||||
model.put("captcha", "NONE");
|
||||
}
|
||||
model.put("state", authTokenService.genRandomJwt());
|
||||
//load Social Sign On Providers
|
||||
|
||||
@@ -63,7 +63,9 @@ maxkey.crypto.password.encoder =bcrypt
|
||||
#Login configuration #
|
||||
############################################################################
|
||||
#enable captcha
|
||||
maxkey.login.captcha =${LOGIN_CAPTCHA:false}
|
||||
maxkey.login.captcha =${LOGIN_CAPTCHA:true}
|
||||
#TEXT ARITHMETIC
|
||||
maxkey.login.captcha.type =${LOGIN_CAPTCHA:TEXT}
|
||||
#enable two factor,use one time password
|
||||
maxkey.login.mfa =${LOGIN_MFA_ENABLED:true}
|
||||
#TimeBasedOtpAuthn MailOtpAuthn SmsOtpAuthnYunxin SmsOtpAuthnAliyun SmsOtpAuthnTencentCloud
|
||||
|
||||
@@ -68,7 +68,9 @@ public class LoginEntryPoint {
|
||||
Institutions inst = (Institutions)WebContext.getAttribute(WebConstants.CURRENT_INST);
|
||||
model.put("inst", inst);
|
||||
if(applicationConfig.getLoginConfig().isCaptcha()) {
|
||||
model.put("captcha", "true");
|
||||
model.put("captcha", applicationConfig.getLoginConfig().getCaptchaType());
|
||||
}else {
|
||||
model.put("captcha", "NONE");
|
||||
}
|
||||
model.put("state", authTokenService.genRandomJwt());
|
||||
return new Message<HashMap<String , Object>>(model);
|
||||
|
||||
@@ -51,6 +51,8 @@ maxkey.crypto.password.encoder =bcrypt
|
||||
############################################################################
|
||||
#enable captcha
|
||||
maxkey.login.captcha =${LOGIN_CAPTCHA:true}
|
||||
#TEXT ARITHMETIC
|
||||
maxkey.login.captcha.type =${LOGIN_CAPTCHA:ARITHMETIC}
|
||||
#enable two factor,use one time password
|
||||
maxkey.login.mfa =false
|
||||
#Enable kerberos/SPNEGO
|
||||
|
||||
Reference in New Issue
Block a user