Merge pull request #3661 from dataease/pr@dev@feat_scan_login_limit

feat(登录): 禁止扫码创建用户配置
This commit is contained in:
王嘉豪 2022-11-07 16:15:08 +08:00 committed by GitHub
commit 108a21ad62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 84 additions and 28 deletions

View File

@ -20,7 +20,9 @@ public interface AuthUserService {
SysUserEntity getUserBySub(String sub, Integer from);
SysUserEntity getUserByWecomId(String weComId);
SysUserEntity getUserByDingtalkId(String dingtalkId);
SysUserEntity getUserByLarkId(String larkId);
SysUserEntity getUserByLarksuiteId(String larksuiteId);
@ -61,5 +63,7 @@ public interface AuthUserService {
void clearAllLock();
Boolean checkScanCreateLimit();
}

View File

@ -3,6 +3,7 @@ package io.dataease.auth.service.impl;
import io.dataease.auth.api.dto.CurrentRoleDto;
import io.dataease.auth.entity.AccountLockStatus;
import io.dataease.auth.entity.SysUserEntity;
import io.dataease.commons.constants.ParamConstants;
import io.dataease.commons.utils.CodingUtil;
import io.dataease.exception.DataEaseException;
import io.dataease.ext.*;
@ -28,6 +29,7 @@ import io.dataease.plugins.xpack.loginlimit.service.LoginLimitXpackService;
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
import io.dataease.plugins.xpack.wecom.service.WecomXpackService;
import io.dataease.service.system.SystemParameterService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -57,6 +59,9 @@ public class AuthUserServiceImpl implements AuthUserService {
@Resource
private SysLoginLimitMapper sysLoginLimitMapper;
@Resource
private SystemParameterService systemParameterService;
/**
* 此处需被F2CRealm登录认证调用 也就是说每次请求都会被调用 所以最好加上缓存
*
@ -328,4 +333,10 @@ public class AuthUserServiceImpl implements AuthUserService {
SysLoginLimitExample example = new SysLoginLimitExample();
sysLoginLimitMapper.deleteByExample(example);
}
@Override
public Boolean checkScanCreateLimit() {
String value = systemParameterService.getValue(ParamConstants.BASIC.SCAN_CREATE_USER.getValue());
return StringUtils.isNotBlank(value) && StringUtils.equals("true", value);
}
}

View File

@ -125,6 +125,8 @@ public interface ParamConstants {
LOGIN_LIMIT_RELIEVETIMES("loginlimit.relieveTimes"),
LOGIN_LIMIT_OPEN("loginlimit.open"),
SCAN_CREATE_USER("loginlimit.scanCreateUser"),
TEMPLATE_ACCESS_KEY("basic.templateAccessKey");
private String value;

View File

@ -99,6 +99,8 @@ public class XDingtalkServer {
String username = dingUserEntity.getUserid();
SysUserEntity sysUserEntity = authUserService.getUserByDingtalkId(username);
if (null == sysUserEntity) {
if (authUserService.checkScanCreateLimit())
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
String email = StringUtils.isNotBlank(dingUserEntity.getOrg_email()) ? dingUserEntity.getOrg_email() : StringUtils.isNotBlank(dingUserEntity.getEmail()) ? dingUserEntity.getEmail() : (username + "@dingtalk.work");
sysUserService.validateExistUser(username, dingUserEntity.getName(), email);
sysUserService.saveDingtalkCUser(dingUserEntity, email);

View File

@ -100,6 +100,8 @@ public class XLarkServer {
String username = larkUserInfo.getUser_id();
SysUserEntity sysUserEntity = authUserService.getUserByLarkId(username);
if (null == sysUserEntity) {
if (authUserService.checkScanCreateLimit())
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
String email = StringUtils.isNotBlank(larkUserInfo.getEmail()) ? larkUserInfo.getEmail() : (username + "@lark.work");
sysUserService.validateExistUser(username, larkUserInfo.getName(), email);
sysUserService.saveLarkCUser(larkUserInfo, email);

View File

@ -100,6 +100,8 @@ public class XLarksuiteServer {
String username = larkUserInfo.getUser_id();
SysUserEntity sysUserEntity = authUserService.getUserByLarksuiteId(username);
if (null == sysUserEntity) {
if (authUserService.checkScanCreateLimit())
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
String email = StringUtils.isNotBlank(larkUserInfo.getEmail()) ? larkUserInfo.getEmail() : (username + "@larksuite.work");
sysUserService.validateExistUser(username, larkUserInfo.getName(), email);
sysUserService.saveLarksuiteCUser(larkUserInfo, email);

View File

@ -103,6 +103,8 @@ public class XWecomServer {
SysUserEntity sysUserEntity = authUserService.getUserByWecomId(userId);
if (null == sysUserEntity) {
if (authUserService.checkScanCreateLimit())
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
Object emailObj = ObjectUtils.isEmpty(userMap.get("biz_mail")) ? userMap.get("email") : userMap.get("biz_mail");
String email = ObjectUtils.isEmpty(emailObj) ? (userId + "@wecom.work") : emailObj.toString();
sysUserService.validateExistUser(userId, userMap.get("name").toString(), email);

View File

@ -121,6 +121,10 @@ public class SystemParameterService {
boolean open = StringUtils.equals("true", param.getParamValue());
result.setOpen(open ? "true" : "false");
}
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.SCAN_CREATE_USER.getValue())) {
boolean open = StringUtils.equals("true", param.getParamValue());
result.setScanCreateUser(open ? "true" : "false");
}
}
}

View File

@ -56,7 +56,7 @@ i18n_chart_count=Count*
i18n_excel_have_merge_region=Excel has merged region
i18n_cron_expression_error=Cron expression error
i18n_same_folder_can_not_repeat=Name is already used in the same folder
i18n_select_diff_folder= Select Diff Folder
i18n_select_diff_folder=Select Diff Folder
i18n_default_panel=Default Dashboard
i18n_panel_list=Dashboard
i18n_processing_data=Processing data now, Refresh later
@ -72,7 +72,7 @@ i18n_sync_job_exists=There is already a synchronization task running, please try
i18n_datasource_check_fail=Invalid,please check config
i18n_not_find_user=Can not find user.
i18n_sql_not_empty=SQL can not be empty.
i18n_datasource_not_allow_delete_msg= datasets are using this data source and cannot be deleted
i18n_datasource_not_allow_delete_msg=datasets are using this data source and cannot be deleted
i18n_task_name_repeat=Name is used in same data set
i18n_id_or_pwd_error=Invalid ID or password
i18n_user_do_not_exist=User do not exist
@ -224,26 +224,20 @@ I18N_END_TIME=End time
I18N_STATUS=Status
I18N_DATA=Data
I18N_SYNC_LOG=Sync logI18N_DS_INVALID
I18N_USER_DONOT_EXIST=User does not exist
I18N_USER_SOURCE_PWD_ERROR=Source password error
I18N_USER_PWD_FORMAT_ERROR=Password format error
I18N_DS_INVALID=Datasource is invalid
I18N_DS_INVALID_TABLE=Datasource has invalid tables
I18N_ACCOUNT_LOCKED=Account\u3010%s\u3011is locked(Please contact the administrator to unlock or try again in %s minutes)
I18N_PANEL_EXIST=The current panel name already exists under this directory
I18N_DATASET_GROUP_EXIST=The current dataset grouping name already exists under this directory
I18N_NOT_JAR=File is not jar!
I18N_APP_NO_VIEW_ERROR=This panel don't have views
I18N_APP_TEMPLATE_VIEW_ERROR=This panel have view from template
I18N_APP_NO_DATASET_ERROR=This panel don't have dataset
I18N_APP_ERROR_DATASET=This panel have dataset witch type is excel or api
I18N_APP_NO_DATASOURCE=This panel don't have datasource
I18N_APP_ONE_DATASOURCE_TIPS=This panel should have only one datasource
I18N_PROHIBIT_SCANNING_TO_CREATE_USER=Prohibit scanning code to create user

View File

@ -56,7 +56,7 @@ i18n_chart_count=\u8BB0\u5F55\u6570*
i18n_excel_have_merge_region=Excel \u5B58\u5728\u5408\u5E76\u5355\u5143\u683C
i18n_cron_expression_error=Cron \u8868\u8FBE\u5F0F\u6821\u9A8C\u9519\u8BEF
i18n_same_folder_can_not_repeat=\u540C\u4E00\u76EE\u5F55\u4E0B\u8BE5\u540D\u79F0\u5DF2\u88AB\u4F7F\u7528
i18n_select_diff_folder= \u8BF7\u9009\u62E9\u4E0D\u540C\u7684\u76EE\u5F55
i18n_select_diff_folder=\u8BF7\u9009\u62E9\u4E0D\u540C\u7684\u76EE\u5F55
i18n_default_panel=\u9ED8\u8BA4\u4EEA\u8868\u677F
i18n_panel_list=\u4EEA\u8868\u677F
i18n_processing_data=\u6B63\u5728\u5904\u7406\u6570\u636E\uFF0C\u7A0D\u540E\u5237\u65B0
@ -72,7 +72,7 @@ i18n_sync_job_exists=\u5DF2\u7ECF\u6709\u540C\u6B65\u4EFB\u52A1\u5728\u8FD0\u884
i18n_datasource_check_fail=\u6821\u9A8C\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u4FE1\u606F
i18n_not_find_user=\u672A\u627E\u5230\u7528\u6237
i18n_sql_not_empty=SQL \u4E0D\u80FD\u4E3A\u7A7A
i18n_datasource_not_allow_delete_msg= \u4E2A\u6570\u636E\u96C6\u6B63\u5728\u4F7F\u7528\u6B64\u6570\u636E\u6E90\uFF0C\u65E0\u6CD5\u5220\u9664
i18n_datasource_not_allow_delete_msg=\u4E2A\u6570\u636E\u96C6\u6B63\u5728\u4F7F\u7528\u6B64\u6570\u636E\u6E90\uFF0C\u65E0\u6CD5\u5220\u9664
i18n_task_name_repeat=\u540C\u4E00\u6570\u636E\u96C6\u4E0B\u4EFB\u52A1\u540D\u79F0\u5DF2\u88AB\u4F7F\u7528
i18n_id_or_pwd_error=\u65E0\u6548\u7684ID\u6216\u5BC6\u7801
i18n_user_do_not_exist=\u7528\u6237\u4E0D\u5B58\u5728
@ -224,18 +224,12 @@ I18N_END_TIME=\u7ED3\u675F\u65F6\u95F4
I18N_STATUS=\u72B6\u6001
I18N_DATA=\u6570\u636E
I18N_SYNC_LOG=\u540C\u6B65\u65E5\u5FD7
I18N_USER_DONOT_EXIST=\u7528\u6237\u4E0D\u5B58\u5728
I18N_USER_SOURCE_PWD_ERROR=\u539F\u59CB\u5BC6\u7801\u9519\u8BEF
I18N_USER_PWD_FORMAT_ERROR=\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF
I18N_DS_INVALID=\u6570\u636E\u6E90\u65E0\u6548
I18N_DS_INVALID_TABLE=\u6570\u636E\u6E90\u4E2D\u6709\u65E0\u6548\u7684\u8868
I18N_ACCOUNT_LOCKED=\u8D26\u53F7\u3010%s\u3011\u5DF2\u9501\u5B9A(\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u89E3\u9501\u6216%s\u5206\u949F\u540E\u91CD\u8BD5)
I18N_PANEL_EXIST=\u5F53\u524D\u4EEA\u8868\u677F\u540D\u79F0\u5728\u8BE5\u76EE\u5F55\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
I18N_DATASET_GROUP_EXIST=\u5F53\u524D\u6570\u636E\u96C6\u5206\u7EC4\u540D\u79F0\u5728\u8BE5\u76EE\u5F55\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
I18N_NOT_JAR=\u6587\u4EF6\u4E0D\u662F jar \u5305!
@ -245,4 +239,5 @@ I18N_APP_NO_DATASET_ERROR=\u8BE5\u4EEA\u8868\u7248\u6CA1\u6709\u6570\u636E\u96C6
I18N_APP_ERROR_DATASET=\u4EEA\u8868\u677F\u4E2D\u4E0D\u80FD\u5B58\u5728API\u6570\u636E\u6E90\u6216\u8005Excel\u6570\u636E\u96C6
I18N_APP_NO_DATASOURCE=\u6CA1\u6709\u627E\u5230\u6570\u636E\u6E90
I18N_APP_ONE_DATASOURCE_TIPS=\u8BE5\u4EEA\u8868\u677F\u53EA\u80FD\u5B58\u5728\u4E00\u4E2A\u6570\u636E\u6E90
I18N_PROHIBIT_SCANNING_TO_CREATE_USER=\u7981\u6B62\u626B\u7801\u521B\u5EFA\u7528\u6237\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01

View File

@ -56,7 +56,7 @@ i18n_chart_count=\u8A18\u9304\u6578*
i18n_excel_have_merge_region=Excel\u5B58\u5728\u5408\u4E26\u55AE\u5143\u683C
i18n_cron_expression_error=Cron\u8868\u9054\u5F0F\u6821\u9A57\u932F\u8AA4
i18n_same_folder_can_not_repeat=\u540C\u4E00\u76EE\u9304\u4E0B\u8A72\u540D\u7A31\u5DF2\u88AB\u4F7F\u7528
i18n_select_diff_folder= \u8BF7\u9009\u62E9\u4E0D\u540C\u7684\u76EE\u5F55
i18n_select_diff_folder=\u8BF7\u9009\u62E9\u4E0D\u540C\u7684\u76EE\u5F55
i18n_default_panel=\u9ED8\u8A8D\u5100\u8868\u677F
i18n_panel_list=\u5100\u8868\u677F
i18n_processing_data=\u6B63\u5728\u8655\u7406\u6578\u64DA\uFF0C\u7A0D\u5F8C\u5237\u65B0
@ -72,7 +72,7 @@ i18n_sync_job_exists=\u5DF2\u7D93\u6709\u540C\u6B65\u4EFB\u52D9\u5728\u904B\u884
i18n_datasource_check_fail=\u6821\u9A57\u5931\u6557\uFF0C\u8ACB\u6AA2\u67E5\u914D\u7F6E\u4FE1\u606F
i18n_not_find_user=\u672A\u627E\u5230\u7528\u6236
i18n_sql_not_empty=SQL \u4E0D\u80FD\u70BA\u7A7A
i18n_datasource_not_allow_delete_msg= \u500B\u6578\u64DA\u96C6\u6B63\u5728\u4F7F\u7528\u6B64\u6578\u64DA\u6E90\uFF0C\u7121\u6CD5\u522A\u9664
i18n_datasource_not_allow_delete_msg=\u500B\u6578\u64DA\u96C6\u6B63\u5728\u4F7F\u7528\u6B64\u6578\u64DA\u6E90\uFF0C\u7121\u6CD5\u522A\u9664
i18n_task_name_repeat=\u540C\u4E00\u6578\u64DA\u96C6\u4E0B\u4EFB\u52D9\u540D\u7A31\u5DF2\u88AB\u4F7F\u7528
i18n_id_or_pwd_error=\u7121\u6548\u7684ID\u6216\u5BC6\u78BC
i18n_user_do_not_exist=\u7528\u6236\u4E0D\u5B58\u5728
@ -220,18 +220,12 @@ I18N_END_TIME=\u7D50\u675F\u6642\u9593
I18N_STATUS=\u72C0\u614B
I18N_DATA=\u6578\u64DA
I18N_SYNC_LOG=\u540C\u6B65\u65E5\u8A8C
I18N_USER_DONOT_EXIST=\u7528\u6236\u4E0D\u5B58\u5728
I18N_USER_SOURCE_PWD_ERROR=\u539F\u59CB\u5BC6\u78BC\u932F\u8AA4
I18N_USER_PWD_FORMAT_ERROR=\u5BC6\u78BC\u683C\u5F0F\u932F\u8AA4
I18N_DS_INVALID=\u6578\u64DA\u6E90\u7121\u6548
I18N_DS_INVALID_TABLE=\u6578\u64DA\u6E90\u4E2D\u6709\u7121\u6548\u7684\u8868
I18N_ACCOUNT_LOCKED=\u8CEC\u865F\u3010%s\u3011\u5DF2\u9396\u5B9A(\u8ACB\u806F\u7CFB\u7BA1\u7406\u54E1\u89E3\u9396\u6216%s\u5206\u9418\u5F8C\u91CD\u8A66)
I18N_PANEL_EXIST=\u7576\u524D\u5100\u9336\u95C6\u540D\u7A31\u5728\u8A72\u76EE\u9304\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
I18N_DATASET_GROUP_EXIST=\u7576\u524D\u6578\u64DA\u96C6\u5206\u7D44\u540D\u7A31\u5728\u8A72\u76EE\u9304\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
I18N_NOT_JAR=\u6587\u4EF6\u4E0D\u662F jar \u5305!
@ -241,3 +235,4 @@ I18N_APP_NO_DATASET_ERROR=\u8A72\u5100\u8868\u7248\u6C92\u6709\u6578\u64DA\u96C6
I18N_APP_ERROR_DATASET=\u5100\u8868\u677F\u4E2D\u4E0D\u80FD\u5B58\u5728API\u6578\u64DA\u6E90\u6216\u8005Excel\u6578\u64DA\u96C6
I18N_APP_NO_DATASOURCE=\u6C92\u6709\u627E\u5230\u6578\u64DA\u6E90
I18N_APP_ONE_DATASOURCE_TIPS=\u8A72\u5100\u8868\u677F\u53EA\u80FD\u5B58\u5728\u4E00\u500B\u6578\u64DA\u6E90
I18N_PROHIBIT_SCANNING_TO_CREATE_USER=\u7981\u6B62\u6383\u78BC\u5275\u5EFA\u7528\u6236\uFF0C\u8ACB\u806F\u7CFB\u7BA1\u7406\u54E1\uFF01

View File

@ -259,10 +259,10 @@ export default {
return this.$store.state.user.loginMsg
},
qrTypes() {
return this.loginTypes && this.loginTypes.filter(item => item > 3 && item < 7) || []
return this.loginTypes && this.loginTypes.filter(item => item > 3 && item < 8) || []
},
radioTypes() {
return this.loginTypes && this.loginTypes.filter(item => item < 4 || item > 6) || []
return this.loginTypes && this.loginTypes.filter(item => item < 4 || item > 7) || []
}
},
watch: {

View File

@ -159,6 +159,13 @@
component-name="LoginLimitSetting"
/>
<plugin-com
v-if="isPluginLoaded && scanOpen"
ref="ScanLimitSetting"
:form="formInline"
component-name="ScanLimitSetting"
/>
<el-form-item
:label="
$t('commons.yes') + $t('commons.no') + $t('display.openMarketPage')
@ -199,7 +206,7 @@
<script>
import { basicInfo, updateInfo } from '@/api/system/basic'
import { ldapStatus, oidcStatus, casStatus } from '@/api/user'
import { ldapStatus, oidcStatus, casStatus, wecomStatus, dingtalkStatus, larkStatus, larksuiteStatus } from '@/api/user'
import bus from '@/utils/bus'
import operator from './Operator'
import msgCfm from '@/components/msgCfm'
@ -260,6 +267,12 @@ export default {
originLoginType: null
}
},
computed: {
scanOpen() {
return this.loginTypes && this.loginTypes.some(item => item > 3 && item < 8)
}
},
beforeCreate() {
ldapStatus().then((res) => {
if (res.success && res.data) {
@ -277,6 +290,29 @@ export default {
if (res.success && res.data) {
this.loginTypes.push(3)
}
}),
wecomStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(4)
}
})
dingtalkStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(5)
}
})
larkStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(6)
}
})
larksuiteStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(7)
}
})
},
created() {
@ -305,6 +341,7 @@ export default {
this.originLoginType = this.formInline.loginType
}
this.formInline.open = (this.formInline.open && this.formInline.open === 'true')
this.formInline.scanCreateUser = (this.formInline.scanCreateUser && this.formInline.scanCreateUser === 'true')
this.$nextTick(() => {
this.$refs.formInline.clearValidate()
@ -386,6 +423,12 @@ export default {
paramValue: this.formInline.open,
type: 'text',
sort: 3
},
{
paramKey: 'loginlimit.scanCreateUser',
paramValue: this.formInline.scanCreateUser,
type: 'text',
sort: 3
}
]