Skip to content

Commit

Permalink
Merge pull request #20 from hiparker/development
Browse files Browse the repository at this point in the history
2.0.1
  • Loading branch information
hiparker committed Aug 9, 2022
2 parents 786a530 + c62b96b commit dfd6260
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 37 deletions.
16 changes: 8 additions & 8 deletions db-file/2.0版本/opsli-boot.sql
Expand Up @@ -4499,14 +4499,14 @@ CREATE TABLE `sys_user` (
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO `sys_user` VALUES (1, 'system', 'TS{MTY1OTM2NzA0MjMzOA==}$2a$10$FtVMZrf/LeM4ikU2ZXO8XuhmRDpJmIxLVm6Fa3ZEM8jVgZ2CFhuH6', '2', '1', '超级管理员', '15321010110', '112', 'http://upload.bedebug.com/20220802/1660928576913664278HC1G.jpg', '', 'meet.parker@foxmail.com', '没有自学能力的人没有未来', '', '0', '0', 0, '1', '0', 95, 1, '2020-09-25 15:03:22', 1, '2021-05-04 01:59:11', '2022-08-02 15:29:33');
INSERT INTO `sys_user` VALUES (1313694379541635074, 'demo', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '租户内部管理员', '15311111111', 'test_001', 'http://upload.bedebug.com/20211013/1635589382475625280EW3N.jpg', '', 'meet.parker1@foxmail.com', NULL, NULL, '1', '0', 1, '0', '0', 6, 1, '2020-10-06 23:15:22', 1465879900211294210, '2021-12-01 16:42:13', '2022-07-27 13:49:16');
INSERT INTO `sys_user` VALUES (1315218541317750785, 'zhangsan', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '张三', NULL, '123123', NULL, '', NULL, NULL, NULL, '1', '0', 1, '0', '0', 3, 1, '2020-10-11 17:11:50', 1, '2021-06-11 17:44:11', '2022-07-20 14:30:20');
INSERT INTO `sys_user` VALUES (1315224823500120066, 'lyf', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '刘亦菲', NULL, '0101001', NULL, '', NULL, NULL, NULL, '1', '0', 1, '0', '0', 0, 1313694379541635074, '2020-10-11 17:36:48', 1313694379541635074, '2020-10-11 17:36:48', '2022-07-20 14:30:20');
INSERT INTO `sys_user` VALUES (1465171199435362305, 'admin', 'TS{MTY1OTM2NDMzMzM5Nw==}$2a$10$2GTqJeztWRLOYDoB2EStm.FoncwpHG4GGtieD7qZbND1.cwjXx34u', '2', '1', '系统管理员', NULL, '01001', NULL, '', NULL, NULL, NULL, '1', '0', 0, '1', '0', 6, 1, '2021-11-29 12:10:10', 1, '2022-07-26 20:16:02', '2022-08-01 22:32:13');
INSERT INTO `sys_user` VALUES (1465879900211294210, 'tenant', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '租户管理员', '15300000000', '123123', NULL, '', 'meet.parker2@foxmail.com', NULL, NULL, '0', '1', 1, '0', '0', 1, 1, '2021-12-01 11:06:17', 1, '2021-12-01 11:06:53', '2022-07-27 13:49:20');
INSERT INTO `sys_user` VALUES (1465886867659096066, 'dept', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '部门管理员', NULL, '123213213', NULL, '', NULL, NULL, NULL, '1', '0', 1, '0', '0', 0, 1313694379541635074, '2021-12-01 11:33:59', 1313694379541635074, '2021-12-01 11:33:59', '2022-07-20 14:30:20');
INSERT INTO `sys_user` VALUES (1465991640378986498, 'songyi', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '宋轶', NULL, '432431', NULL, '', NULL, NULL, NULL, '1', '0', 1, '0', '0', 0, 1465886867659096066, '2021-12-01 18:30:19', 1465886867659096066, '2021-12-01 18:30:19', '2022-07-20 14:30:20');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1, 'system', 'TS{MTY1OTM2NzA0MjMzOA==}$2a$10$FtVMZrf/LeM4ikU2ZXO8XuhmRDpJmIxLVm6Fa3ZEM8jVgZ2CFhuH6', '2', '1', '超级管理员', '15321010110', '112', 'http://upload.bedebug.com/20220802/1660928576913664278HC1G.jpg', '', 'meet.parker@foxmail.com', '没有自学能力的人没有未来', '', '0', '0', 0, '1', '0', 95, 1, '2020-09-25 15:03:22', 1, '2021-05-04 01:59:11', '2022-08-02 15:29:33');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1313694379541635074, 'demo', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '租户内部管理员', '13301225424', 'test_001', 'http://upload.bedebug.com/20220809/1660188426197843638MXWG.jpg', '', 'meet.parker1@foxmail.com', NULL, NULL, '1', '0', 1, '0', '0', 6, 1, '2020-10-06 23:15:22', 1465879900211294210, '2021-12-01 16:42:13', '2022-08-09 13:55:05');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1315218541317750785, 'zhangsan', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '张三', '55555555555', '123123', NULL, '', 'meet.parker3@foxmail.com', NULL, NULL, '1', '0', 1, '0', '0', 3, 1, '2020-10-11 17:11:50', 1, '2021-06-11 17:44:11', '2022-08-09 14:01:18');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1315224823500120066, 'lyf', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '刘亦菲', '44444444444', '0101001', NULL, '', 'meet.parker4@foxmail.com', NULL, NULL, '1', '0', 1, '0', '0', 0, 1313694379541635074, '2020-10-11 17:36:48', 1313694379541635074, '2020-10-11 17:36:48', '2022-08-09 14:01:22');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1465171199435362305, 'admin', 'TS{MTY1OTM2NDMzMzM5Nw==}$2a$10$2GTqJeztWRLOYDoB2EStm.FoncwpHG4GGtieD7qZbND1.cwjXx34u', '2', '1', '系统管理员', '33333333333', '01001', 'http://upload.bedebug.com/20220809/16605552760947393781AWR.jpg', '', 'meet.parker5@foxmail.com', NULL, NULL, '1', '0', 0, '1', '0', 6, 1, '2021-11-29 12:10:10', 1, '2022-07-26 20:16:02', '2022-08-09 14:01:26');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1465879900211294210, 'tenant', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '租户管理员', '17310558930', '123123', 'http://upload.bedebug.com/20220809/166121046267039280RQ81U.jpg', '', 'meet.parker2@foxmail.com', NULL, NULL, '0', '1', 1, '0', '0', 1, 1, '2021-12-01 11:06:17', 1, '2021-12-01 11:06:53', '2022-08-09 13:55:40');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1465886867659096066, 'dept', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '部门管理员', '22222222222', '123213213', 'http://upload.bedebug.com/20220809/16610489376695984679HUA.jpg', '', 'meet.parker6@foxmail.com', NULL, NULL, '1', '0', 1, '0', '0', 0, 1313694379541635074, '2021-12-01 11:33:59', 1313694379541635074, '2021-12-01 11:33:59', '2022-08-09 14:01:30');
INSERT INTO `sys_user`(`id`, `username`, `password`, `password_level`, `enable`, `real_name`, `mobile`, `no`, `avatar`, `login_ip`, `email`, `sign`, `remark`, `iz_exist_org`, `iz_tenant_admin`, `tenant_id`, `enable_switch_tenant`, `deleted`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `ts`) VALUES (1465991640378986498, 'songyi', 'TS{MTY1ODI5ODUzMzMwOA==}$2a$10$TS0LnHPhQT87rEpFi1A60.BeTQ80vCRGGL.5CPTqb61eCzP8HzueK', '2', '1', '宋轶', '11111111111', '432431', 'http://upload.bedebug.com/20220809/1661003971159749330PV6N.jpg', '', 'meet.parker7@foxmail.com', NULL, NULL, '1', '0', 1, '0', '0', 0, 1465886867659096066, '2021-12-01 18:30:19', 1465886867659096066, '2021-12-01 18:30:19', '2022-08-09 14:01:33');
COMMIT;

-- ----------------------------
Expand Down
Expand Up @@ -67,7 +67,11 @@ protected void configure(HttpSecurity http) throws Exception {
.frameOptions().disable()
.and()
// 关闭csrf token认证不需要csrf防护
.csrf().disable();
.csrf().disable()
// 关闭Session会话管理器 JWT 不需要
.sessionManagement().disable()
// 关闭记住我功能 JWT 不需要
.rememberMe().disable();

// 初始化 initAuthorizeRequests
this.initAuthorizeRequests(http);
Expand All @@ -78,15 +82,6 @@ protected void configure(HttpSecurity http) throws Exception {
* @param http http
*/
private void initAuthorizeRequests(HttpSecurity http) throws Exception {
// 设置URL 未登陆前可访问URL
List<String> anonymousList = authProperties.getUrlExclusion().getAnonymous();
if(null != anonymousList){
String[] urlExclusionArray = anonymousList.toArray(new String[0]);
http.authorizeRequests()
// URL 未登陆前可访问
.antMatchers(urlExclusionArray).anonymous();
}

// 设置URL白名单
List<String> permitAll = authProperties.getUrlExclusion().getPermitAll();
if(null != permitAll){
Expand All @@ -105,6 +100,8 @@ private void initAuthorizeRequests(HttpSecurity http) throws Exception {
http.addFilterBefore(new JwtAuthenticationTokenFilter(uidUserDetailDetailService),
UsernamePasswordAuthenticationFilter.class);



// 异常处理
http.exceptionHandling()
.accessDeniedHandler(accessDeniedHandler)
Expand Down
Expand Up @@ -37,6 +37,7 @@
import org.opsli.modulars.system.dict.service.IDictDetailService;
import org.opsli.modulars.system.dict.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -54,6 +55,8 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys

@Autowired(required = false)
private DictDetailMapper mapper;

@Lazy
@Autowired
private IDictService iDictService;

Expand Down
Expand Up @@ -35,7 +35,7 @@ public class LoginModel {
private String principal;

/** 密码 */
@Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_SECURITY_PASSWORD})
@Validator({ValidatorType.IS_NOT_NULL})
@ValidatorLenMin(6)
private String password;

Expand Down
Expand Up @@ -5,6 +5,7 @@
import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.api.wrapper.system.user.UserOrgRefModel;
import org.opsli.common.enums.DictType;
import org.opsli.common.utils.IPUtil;
import org.opsli.core.utils.UserUtil;
import org.springframework.util.ObjectUtils;

Expand All @@ -27,7 +28,7 @@ public static LoginLogsModel getUserLoginModel(HttpServletRequest request, UserM
loginInfo.setUsername(user.getUsername());
loginInfo.setRealName(user.getRealName());
// *** 需要确保 user对象的ip信息是有值的
loginInfo.setRemoteAddr(user.getLoginIp());
loginInfo.setRemoteAddr(IPUtil.getClientAddressBySingle(request));
String header = request.getHeader("User-Agent");
loginInfo.setUserAgent(header);

Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.opsli.modulars.system.role.service.IRoleMenuRefService;
import org.opsli.modulars.system.user.service.IUserRoleRefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -48,6 +49,8 @@ public class RoleMenuRefServiceImpl extends ServiceImpl<RoleMenuRefMapper,SysRol

@Autowired(required = false)
private RoleMenuRefMapper mapper;

@Lazy
@Autowired
private IUserRoleRefService iUserRoleRefService;

Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.opsli.modulars.system.user.service.IUserOrgRefService;
import org.opsli.modulars.system.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -72,8 +73,11 @@ public class UserOrgRefServiceImpl extends ServiceImpl<UserOrgRefMapper, SysUser
@Autowired(required = false)
private UserOrgRefMapper mapper;

@Lazy
@Autowired
private IUserService iUserService;

@Lazy
@Autowired
private ISysOrgService iSysOrgService;

Expand Down
Expand Up @@ -46,6 +46,7 @@
import org.opsli.modulars.system.user.service.IUserRoleRefService;
import org.opsli.modulars.system.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -64,12 +65,15 @@ public class UserRoleRefServiceImpl extends ServiceImpl<UserRoleRefMapper, SysUs
@Autowired(required = false)
private UserRoleRefMapper mapper;

@Lazy
@Autowired
private IRoleService iRoleService;

@Lazy
@Autowired
private IUserService iUserService;

@Lazy
@Autowired
private IMenuService iMenuService;

Expand Down
Expand Up @@ -17,12 +17,10 @@

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
Expand All @@ -46,7 +44,6 @@
import org.opsli.core.utils.UserUtil;
import org.opsli.core.utils.VerificationCodeUtil;
import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.menu.service.IMenuService;
import org.opsli.modulars.system.role.entity.SysRole;
import org.opsli.modulars.system.role.service.IRoleService;
import org.opsli.modulars.system.user.entity.SysUser;
Expand All @@ -55,7 +52,7 @@
import org.opsli.modulars.system.user.service.IUserRoleRefService;
import org.opsli.modulars.system.user.service.IUserService;
import org.opsli.plugins.security.utils.PasswordUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -72,6 +69,7 @@
* @date 2020-09-16 17:33
*/
@AllArgsConstructor
@Lazy
@Service
public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserModel> implements IUserService {

Expand Down
Expand Up @@ -45,9 +45,6 @@ public class AuthProperties {
@Data
public static class UrlExclusion {

/** 未登陆状态下可以访问 */
private List<String> anonymous;

/** 无限制 */
private List<String> permitAll;

Expand Down
17 changes: 7 additions & 10 deletions opsli-starter/src/main/resources/application.yaml
Expand Up @@ -164,17 +164,7 @@ opsli:
credentials-expired: -1
# 排除过滤URL
url-exclusion:
# 未登陆状态下可以访问
anonymous:
- "/captcha"
- "/system/slipCount"
- "/system/login"
- "/system/login-by-code"
# 无限制
permit-all:
- "/api/*/common/public-key"
- "/api/*/common/email/create-code"
- "/api/*/common/mobile/create-code"
- "/swagger-ui.html"
- "/doc.html"
- "/swagger-resources/**"
Expand All @@ -183,6 +173,13 @@ opsli:
- "/swagger/**"
- "/v2/api-docs"
- "/druid/**"
- "/captcha"
- "/system/slipCount"
- "/system/login"
- "/system/login-by-code"
- "/api/*/common/public-key"
- "/api/*/common/email/create-code"
- "/api/*/common/mobile/create-code"

# 超级管理员账号
super-admin: system
Expand Down

0 comments on commit dfd6260

Please sign in to comment.