From feaa59020c5b95f989c782122a32549439cf3f46 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Tue, 3 Oct 2023 21:25:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.0=E3=80=91=E3=80=90auth=E3=80=91?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE=E5=AF=86=E7=A0=81=E7=AD=96?= =?UTF-8?q?=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/expander/LoginConfigExpander.java | 68 +++++++++++++++---- ...8.0.0_20231003_2036__init_login_config.sql | 6 +- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java b/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java index afd4c8a99..aff52c6c2 100644 --- a/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java +++ b/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java @@ -11,19 +11,6 @@ import cn.stylefeng.roses.kernel.config.api.context.ConfigContext; */ public class LoginConfigExpander { - /** - * 登录账号密码登录最大的错误次数 - *

- * 超过此次数则冻结账号 - * - * @author fengshuonan - * @since 2023/10/3 20:25 - */ - public static Integer getMaxErrorLoginCount() { - return ConfigContext.me() - .getSysConfigValueWithDefault("SYS_LOGIN_MAX_ERROR_LOGIN_COUNT", Integer.class, LoginCacheConstants.MAX_ERROR_LOGIN_COUNT); - } - /** * 获取单账号单端登录的开关 *

@@ -50,7 +37,20 @@ public class LoginConfigExpander { } /** - * 口令最小长度 + * 密码策略:密码最大重试次数 + *

+ * 超过此次数则冻结账号 + * + * @author fengshuonan + * @since 2023/10/3 20:25 + */ + public static Integer getMaxErrorLoginCount() { + return ConfigContext.me() + .getSysConfigValueWithDefault("SYS_LOGIN_MAX_ERROR_LOGIN_COUNT", Integer.class, LoginCacheConstants.MAX_ERROR_LOGIN_COUNT); + } + + /** + * 密码策略:口令最小长度 * * @author fengshuonan * @since 2023/10/3 20:39 @@ -59,4 +59,44 @@ public class LoginConfigExpander { return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_MIN_PASSWORD_LENGTH", Integer.class, 6); } + /** + * 密码策略:最少特殊符号数量 + * + * @author fengshuonan + * @since 2023/10/3 20:44 + */ + public static Integer getPasswordMinSpecialSymbolCount() { + return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_PASSWORD_MIN_SPECIAL_SYMBOL_COUNT", Integer.class, 0); + } + + /** + * 密码策略:最少大写字母数量 + * + * @author fengshuonan + * @since 2023/10/3 21:14 + */ + public static Integer getPasswordMinUpperCaseCount() { + return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_PASSWORD_MIN_UPPER_CASE_COUNT", Integer.class, 0); + } + + /** + * 密码策略:最少小写字母数量 + * + * @author fengshuonan + * @since 2023/10/3 21:16 + */ + public static Integer getPasswordMinLowerCaseCount() { + return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_PASSWORD_MIN_LOWER_CASE_COUNT", Integer.class, 0); + } + + /** + * 密码策略:最少数字符号的数量 + * + * @author fengshuonan + * @since 2023/10/3 21:18 + */ + public static Integer getPasswordMinNumberCount() { + return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_PASSWORD_MIN_NUMBER_COUNT", Integer.class, 0); + } + } diff --git a/kernel-d-auth/auth-spring-boot-starter/src/main/resources/db/migration/mysql/V8.0.0_20231003_2036__init_login_config.sql b/kernel-d-auth/auth-spring-boot-starter/src/main/resources/db/migration/mysql/V8.0.0_20231003_2036__init_login_config.sql index f25f6ccbd..ac64b4ca3 100644 --- a/kernel-d-auth/auth-spring-boot-starter/src/main/resources/db/migration/mysql/V8.0.0_20231003_2036__init_login_config.sql +++ b/kernel-d-auth/auth-spring-boot-starter/src/main/resources/db/migration/mysql/V8.0.0_20231003_2036__init_login_config.sql @@ -1,2 +1,6 @@ INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709185484166533121, '密码最大重试次数', 'SYS_LOGIN_MAX_ERROR_LOGIN_COUNT', '5', 'Y', '登录账号密码登录最大的错误次数,超过此次数则冻结账号', 1, 'auth_config', 'N', '2023-10-03 20:35:49', 1339550467939639299, '2023-10-03 20:35:58', 1339550467939639299); -INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709186904454336514, '口令最小长度', 'SYS_LOGIN_MIN_PASSWORD_LENGTH', '6', 'Y', NULL, 1, 'auth_config', 'N', '2023-10-03 20:41:28', 1339550467939639299, NULL, NULL); +INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709186904454336514, '密码策略:口令最小长度', 'SYS_LOGIN_MIN_PASSWORD_LENGTH', '6', 'Y', NULL, 1, 'auth_config', 'N', '2023-10-03 20:41:28', 1339550467939639299, NULL, NULL); +INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709189854337699842, '密码策略:最少特殊符号数量', 'SYS_LOGIN_PASSWORD_MIN_SPECIAL_SYMBOL_COUNT', '0', 'Y', NULL, 1, 'auth_config', 'N', '2023-10-03 20:53:11', 1339550467939639299, '2023-10-03 21:19:56', 1339550467939639299); +INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709196660577406977, '密码策略:最少大写字母数量', 'SYS_LOGIN_PASSWORD_MIN_UPPER_CASE_COUNT', '0', 'Y', NULL, 1, 'auth_config', 'N', '2023-10-03 21:20:14', 1339550467939639299, NULL, NULL); +INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709196708086288385, '密码策略:最少小写字母数量', 'SYS_LOGIN_PASSWORD_MIN_LOWER_CASE_COUNT', '0', 'Y', NULL, 1, 'auth_config', 'N', '2023-10-03 21:20:25', 1339550467939639299, NULL, NULL); +INSERT INTO `sys_config`(`config_id`, `config_name`, `config_code`, `config_value`, `sys_flag`, `remark`, `status_flag`, `group_code`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`) VALUES (1709196753862922241, '密码策略:最少数字符号的数量', 'SYS_LOGIN_PASSWORD_MIN_NUMBER_COUNT', '0', 'Y', NULL, 1, 'auth_config', 'N', '2023-10-03 21:20:36', 1339550467939639299, NULL, NULL);