perf(X-Pack): 登录增加 MFA 机制

This commit is contained in:
fit2cloud-chenyw
2024-12-07 10:12:23 +08:00
parent 38bc011c82
commit a9233f3062
5 changed files with 32 additions and 7 deletions

View File

@@ -4153,6 +4153,7 @@ export default {
status_2: '仅系统管理员',
platform_tips: '第三方登录方式包括OIDC、CAS',
exp_tips: '单位:秒,目前仅在查看账号密码校验 MFA 时生效',
user_enable: '启用 MFA 多因子认证'
user_enable: '启用 MFA 多因子认证',
code_input_msg: '请输入 {0} 位数字'
}
}

View File

@@ -73,10 +73,6 @@ const handleLogin = () => {
if (!formRef.value) return
formRef.value.validate(async (valid: boolean) => {
if (valid) {
/* if (!checkUsername(state.loginForm.username) || !validatePwd(state.loginForm.password)) {
ElMessage.error('用户名或密码错误')
return
} */
const name = state.loginForm.username.trim()
const pwd = state.loginForm.password
if (!wsCache.get(appStore.getDekey)) {
@@ -88,7 +84,12 @@ const handleLogin = () => {
cleanPlatformFlag()
loginApi(param)
.then(res => {
const { token, exp } = res.data
const { token, exp, mfa } = res.data
if (mfa?.enabled) {
xpackLoginHandler.value?.invokeMethod({ methodName: 'toMfa', args: mfa })
duringLogin.value = false
return
}
userStore.setToken(token)
userStore.setExp(exp)
userStore.setTime(Date.now())

View File

@@ -0,0 +1,16 @@
package io.dataease.auth.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class MfaItem implements Serializable {
@Serial
private static final long serialVersionUID = 6647534143991435022L;
private boolean enabled;
private boolean ready;
}

View File

@@ -21,4 +21,11 @@ public class TokenVO implements Serializable {
@Schema(description = "有效期")
private Long exp;
private MfaItem mfa;
public TokenVO(String token, Long exp) {
this.token = token;
this.exp = exp;
}
}