MaxKey 4 месяцев назад
Родитель
Сommit
63ce90286e

+ 11 - 0
maxkey-core/src/main/java/org/dromara/maxkey/configuration/LoginConfig.java

@@ -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();

+ 4 - 2
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts

@@ -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();
     });

+ 3 - 1
maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java

@@ -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

+ 3 - 1
maxkey-webs/maxkey-web-maxkey/src/main/resources/application-maxkey.properties

@@ -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

+ 3 - 1
maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java

@@ -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);

+ 2 - 0
maxkey-webs/maxkey-web-mgt/src/main/resources/application-maxkey-mgt.properties

@@ -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