From 63ce90286eaa35c9dfedc1827d5ffd41e5dbd946 Mon Sep 17 00:00:00 2001 From: MaxKey Date: Mon, 30 Dec 2024 09:09:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/maxkey/configuration/LoginConfig.java | 11 +++++++++++ .../src/app/routes/passport/login/login.component.ts | 6 ++++-- .../maxkey/web/contorller/LoginEntryPoint.java | 4 +++- .../src/main/resources/application-maxkey.properties | 4 +++- .../maxkey/web/contorller/LoginEntryPoint.java | 4 +++- .../main/resources/application-maxkey-mgt.properties | 2 ++ 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/maxkey-core/src/main/java/org/dromara/maxkey/configuration/LoginConfig.java b/maxkey-core/src/main/java/org/dromara/maxkey/configuration/LoginConfig.java index b4bc873c..18d82396 100644 --- a/maxkey-core/src/main/java/org/dromara/maxkey/configuration/LoginConfig.java +++ b/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(); diff --git a/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts b/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts index 16c43b63..676a479f 100644 --- a/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts +++ b/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(); }); diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java b/maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java index b93ccd7c..a80d0ebc 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java +++ b/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 diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-maxkey.properties b/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-maxkey.properties index ea123cf8..3ed1bd79 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-maxkey.properties +++ b/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 diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java index ed43aef2..b123c844 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/web/contorller/LoginEntryPoint.java +++ b/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>(model); diff --git a/maxkey-webs/maxkey-web-mgt/src/main/resources/application-maxkey-mgt.properties b/maxkey-webs/maxkey-web-mgt/src/main/resources/application-maxkey-mgt.properties index 2428b262..383c38f4 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/resources/application-maxkey-mgt.properties +++ b/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