fix: 修复权限相关问题

--bug=1013901 --user=刘瑞斌 【接口权限】使用系统自定义的无任何权限的系统管理员账号,可以查看工作空间、项目、用户等 https://www.tapd.cn/55049933/s/1177397
--bug=1013910 --user=刘瑞斌 【系统设置】用户组与权限列表,点击成员数量报错 https://www.tapd.cn/55049933/s/1177649
--bug=1013900 --user=刘瑞斌 【接口权限】使用自定义的系统管理员账号,可用接口创建项目 https://www.tapd.cn/55049933/s/1177656
--bug=1013911 --user=刘瑞斌 【接口权限】工作空间管理员问题汇总 https://www.tapd.cn/55049933/s/1177705
This commit is contained in:
CaptainB 2022-06-09 12:46:32 +08:00 committed by 刘瑞斌
parent 4a9904cb2c
commit 41535f574b
39 changed files with 73 additions and 83 deletions

View File

@ -18,6 +18,7 @@ import io.metersphere.dto.WorkspaceMemberDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.CheckPermissionService;
import io.metersphere.service.ProjectService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -38,6 +39,7 @@ public class ProjectController {
private ApiTestEnvironmentService apiTestEnvironmentService;
@GetMapping("/listAll")
@RequiresPermissions(PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ)
public List<ProjectDTO> listAll() {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
ProjectRequest request = new ProjectRequest();
@ -47,7 +49,8 @@ public class ProjectController {
/*jenkins项目列表*/
@GetMapping("/listAll/{workspaceId}")
public List<ProjectDTO> jlistAll(@PathVariable String workspaceId) {
@RequiresPermissions(PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ)
public List<ProjectDTO> listAll(@PathVariable String workspaceId) {
ProjectRequest request = new ProjectRequest();
request.setWorkspaceId(workspaceId);
return projectService.getProjectList(request);
@ -83,6 +86,7 @@ public class ProjectController {
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ)
public Pager<List<ProjectDTO>> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, projectService.getProjectList(request));
@ -109,7 +113,7 @@ public class ProjectController {
@PostMapping("/update")
@MsAuditLog(module = OperLogModule.PROJECT_PROJECT_MANAGER, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#Project.id)", content = "#msClass.getLogDetails(#Project.id)", msClass = ProjectService.class)
@RequiresPermissions(PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_EDIT)
@RequiresPermissions(value = {PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_EDIT, PermissionConstants.PROJECT_MANAGER_READ_EDIT}, logical = Logical.OR)
public void updateProject(@RequestBody AddProjectRequest Project) {
projectService.updateProject(Project);
}

View File

@ -45,6 +45,7 @@ public class UserController {
}
@PostMapping("/special/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.SYSTEM_USER_READ)
public Pager<List<User>> getUserList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody io.metersphere.controller.request.UserRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getUserListWithRequest(request));
@ -79,12 +80,14 @@ public class UserController {
}
@PostMapping("/special/ws/member/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.SYSTEM_WORKSPACE_READ)
public Pager<List<User>> getMemberListByAdmin(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryMemberRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getMemberList(request));
}
@PostMapping("/special/ws/member/list/all")
@RequiresPermissions(PermissionConstants.SYSTEM_WORKSPACE_READ)
public List<User> getMemberListByAdmin(@RequestBody QueryMemberRequest request) {
return userService.getMemberList(request);
}
@ -144,19 +147,23 @@ public class UserController {
* 获取工作空间成员用户
*/
@PostMapping("/ws/member/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.WORKSPACE_USER_READ)
public Pager<List<User>> getMemberList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryMemberRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getMemberList(request));
}
@PostMapping("/project/member/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_USER_READ)
public Pager<List<User>> getProjectMemberList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryMemberRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getProjectMemberList(request));
}
@PostMapping("/project/member/list")
public List<User> getProjectMemberListAll(@RequestBody QueryMemberRequest request) {
@GetMapping("/project/member/list")
public List<User> getProjectMemberListAll() {
QueryMemberRequest request = new QueryMemberRequest();
request.setProjectId(SessionUtils.getCurrentProjectId());
return userService.getProjectMemberList(request);
}
@ -169,6 +176,7 @@ public class UserController {
* 获取工作空间成员用户 不分页
*/
@PostMapping("/ws/member/list/all")
@RequiresPermissions(PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ)
public List<User> getMemberList(@RequestBody QueryMemberRequest request) {
return userService.getMemberList(request);
}
@ -223,15 +231,6 @@ public class UserController {
userService.deleteProjectMember(projectId, userId);
}
/**
* ws 下所有相关人员
*/
@GetMapping("/ws/member/list/{workspaceId}")
public List<User> getWsMemberList(@PathVariable String workspaceId) {
return userService.getWsAllMember(workspaceId);
}
/*
* 修改当前用户密码
* */
@ -249,11 +248,6 @@ public class UserController {
return userService.updateUserPassword(request);
}
@PostMapping("/project/member/tester/list")
public List<User> getProjectMember(@RequestBody QueryMemberRequest request) {
return userService.getProjectMember(request);
}
@GetMapping("/search/{condition}")
public List<User> searchUser(@PathVariable String condition) {
return userService.searchUser(condition);

View File

@ -8,6 +8,7 @@ import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.WorkspaceRequest;
import io.metersphere.dto.WorkspaceDTO;
import io.metersphere.dto.WorkspaceMemberDTO;
@ -15,6 +16,7 @@ import io.metersphere.dto.WorkspaceResource;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.UserService;
import io.metersphere.service.WorkspaceService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
@ -63,21 +65,16 @@ public class WorkspaceController {
workspaceService.deleteWorkspace(workspaceId);
}
@PostMapping("list/{goPage}/{pageSize}")
public Pager<List<Workspace>> getWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody WorkspaceRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, workspaceService.getWorkspaceList(request));
}
@PostMapping("list/all/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.SYSTEM_WORKSPACE_READ)
public Pager<List<WorkspaceDTO>> getAllWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody WorkspaceRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, workspaceService.getAllWorkspaceList(request));
}
@GetMapping("/list/userworkspace/{userId}")
public List<Workspace> getWorkspaceListByUserId(@PathVariable String userId) {
return workspaceService.getWorkspaceListByUserId(userId);
@GetMapping("/list/userworkspace")
public List<Workspace> getWorkspaceListByUserId() {
return workspaceService.getWorkspaceListByUserId(SessionUtils.getUserId());
}
@PostMapping("/member/update")

View File

@ -1182,14 +1182,6 @@ public class UserService {
userGroupMapper.deleteByExample(userGroupExample);
}
public List<User> getProjectMember(QueryMemberRequest request) {
String projectId = request.getProjectId();
if (StringUtils.isBlank(projectId)) {
return new ArrayList<>();
}
return extUserGroupMapper.getProjectMemberList(request);
}
public List<User> getWsAllMember(String workspaceId) {
List<String> sourceIds = new ArrayList<>();
ProjectExample projectExample = new ProjectExample();

View File

@ -485,7 +485,7 @@ public class TestCaseReviewService {
private String getReviewName(List<String> userIds, String projectId) {
QueryMemberRequest queryMemberRequest = new QueryMemberRequest();
queryMemberRequest.setProjectId(projectId);
Map<String, String> userMap = userService.getProjectMember(queryMemberRequest)
Map<String, String> userMap = userService.getProjectMemberList(queryMemberRequest)
.stream().collect(Collectors.toMap(User::getId, User::getName));
StringBuilder stringBuilder = new StringBuilder();
String name = "";

View File

@ -127,7 +127,7 @@
}
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.userOptions = response.data;
});
},

View File

@ -837,7 +837,7 @@ export default {
}
},
getPrincipalOptions(option) {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
option.push(...response.data);
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};

View File

@ -1367,7 +1367,7 @@ export default {
this.cancelBatchProcessing();
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -247,7 +247,7 @@
this.httpForm.request = createComponent("DubboSampler");
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()},response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -291,7 +291,7 @@ export default {
});
},
initUserList() {
this.result = this.$post('/user/project/member/list', {projectId: getCurrentProjectID()}, response => {
this.result = this.$get('/user/project/member/list', response => {
this.scheduleReceiverOptions = response.data;
});

View File

@ -169,7 +169,7 @@
this.$emit("createRootModel");
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -195,7 +195,7 @@
this.httpForm.request = createComponent("DubboSampler");
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -139,7 +139,7 @@ export default {
},
methods: {
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -249,7 +249,7 @@ export default {
},
initUserList() {
this.result = this.$post('/user/project/member/list', {projectId: getCurrentProjectID()}, response => {
this.result = this.$get('/user/project/member/list', response => {
this.scheduleReceiverOptions = response.data;
});
},

View File

@ -655,7 +655,7 @@ export default {
}
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.valueArr.userId = response.data;
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};

View File

@ -131,7 +131,7 @@ export default {
initUserList() {
this.result = this.$post('/user/project/member/list', {projectId: getCurrentProjectID()}, response => {
this.result = this.$get('/user/project/member/list', response => {
this.scheduleReceiverOptions = response.data;
});

View File

@ -72,7 +72,7 @@ export default {
methods: {
getCurrentWorkspaceId,
initMenuData() {
this.$get("/workspace/list/userworkspace/" + encodeURIComponent(this.currentUserId), response => {
this.$get("/workspace/list/userworkspace", response => {
this.workspaceList = response.data;
this.wsListCopy = response.data;
let workspace = response.data.filter(r => r.id === getCurrentWorkspaceId());

View File

@ -198,7 +198,7 @@ export default {
return getCurrentUser();
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -223,7 +223,7 @@ export default {
methods: {
getMaintainerOptions() {
let workspaceId = getCurrentWorkspaceId();
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});

View File

@ -161,7 +161,7 @@ export default {
},
initUserList() {
this.result = this.$post('/user/project/member/list', {projectId: getCurrentProjectID()}, response => {
this.result = this.$get('/user/project/member/list', response => {
this.jenkinsReceiverOptions = response.data;
this.reviewReceiverOptions = response.data;
this.defectReceiverOptions = response.data;

View File

@ -156,7 +156,7 @@
})
},
initUsers() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -305,7 +305,7 @@ export default {
this.initTableData();
},
getWorkSpaceList() {
this.$get("/workspace/list/userworkspace/" + encodeURIComponent(getCurrentUserId()), response => {
this.$get("/workspace/list/userworkspace", response => {
let workspaceList = response.data;
let workspaceIds = [];
if (workspaceList) {

View File

@ -140,7 +140,7 @@ export default {
userIds: {required: true, message: this.$t('member.please_choose_member'), trigger: 'blur'},
sourceIds: {required: true, message: this.$t('group.select_belong_source'), trigger: 'blur'}
}
}
};
},
computed: {
typeLabel() {
@ -167,10 +167,12 @@ export default {
this.total = itemCount;
this.memberData = listObject;
}
})
this.$get("/project/get/" + getCurrentProjectID(), res => {
this.currentProject = res.data;
});
if (getCurrentProjectID()) {
this.$get("/project/get/" + getCurrentProjectID(), res => {
this.currentProject = res.data;
});
}
},
open(group, initUserGroupUrl, initUserUrl) {
this.initUserGroupUrl = initUserGroupUrl ? initUserGroupUrl : "/user/group/user/";
@ -206,7 +208,7 @@ export default {
let sourceIds = data.map(d => d.id);
this.$set(this.form, 'userIds', userIds);
this.$set(this.form, 'sourceIds', sourceIds);
})
});
},
editMember() {
this.form.groupId = this.group.id;
@ -220,12 +222,12 @@ export default {
} else {
return false;
}
})
});
},
getUser() {
this.memberResult = this.$get(this.initUserUrl, response => {
this.users = response.data;
})
});
},
removeMember(row) {
this.$confirm(this.$t('member.remove_member').toString(), '', {
@ -251,7 +253,7 @@ export default {
this.groupSource = [];
this.sourceResult = this.$get('/user/group/source/' + row.id + "/" + this.group.id, res => {
this.groupSource = res.data;
})
});
},
addMember() {
if (this.submitType === 'ADD') {
@ -272,7 +274,7 @@ export default {
} else {
return false;
}
})
});
},
getResource() {
this.memberResult = this.$get('/workspace/list/resource/' + this.group.id + "/" + this.group.type, res => {
@ -280,7 +282,7 @@ export default {
if (data) {
this._setResource(this.group.type, data);
}
})
});
},
_setResource(type, data) {
switch (type) {
@ -307,13 +309,14 @@ export default {
this.userSelectDisable = false;
}
}
}
};
</script>
<style scoped>
.member_select, .other_source_select {
display: block;
}
.group-member >>> .el-dialog__body {
padding-top: 0;
}

View File

@ -306,8 +306,8 @@ export default {
name: '',
projectId: row.id
};
this.result = this.$post("/user/project/member/list", param, res => {
this.memberLineData = res.data;
this.result = this.$post("/user/project/member/list/1/100000", param, res => {
this.memberLineData = res.data.listObject;
let arr = this.memberLineData.filter(item => item.id === getCurrentUserId());
if (arr.length > 0) {
window.sessionStorage.setItem(PROJECT_ID, row.id);
@ -321,7 +321,7 @@ export default {
});
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});

View File

@ -270,7 +270,7 @@ export default {
});
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
this.condition.executor = getCurrentUser().id;
});

View File

@ -152,7 +152,7 @@ export default {
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.userOptions = response.data;
});
},

View File

@ -875,7 +875,7 @@ export default {
this.form.testId = '';
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -777,7 +777,7 @@ export default {
this.form.testId = '';
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
},

View File

@ -1163,7 +1163,7 @@ export default {
}
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.valueArr.maintainer = response.data;
});
},

View File

@ -451,7 +451,7 @@ export default {
}
,
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.maintainerOptions = response.data;
});
}

View File

@ -311,7 +311,7 @@ export default {
this.page.result = getIssues(this.page);
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.creatorFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});

View File

@ -312,7 +312,7 @@ export default {
});
},
initUserList() {
this.result = this.$post('/user/project/member/list', {projectId: getCurrentProjectID()}, response => {
this.result = this.$get('/user/project/member/list', response => {
this.scheduleReceiverOptions = response.data;
});
},

View File

@ -288,7 +288,7 @@ export default {
return true;
},
setPrincipalOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()},response => {
this.$get('/user/project/member/list', response => {
this.principalOptions = response.data;
});
},

View File

@ -39,7 +39,7 @@
},
methods: {
setMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.executorOptions = response.data;
});
},

View File

@ -379,7 +379,7 @@ export default {
this.$refs.headerCustom.open(list);
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.valueArr.userId = response.data;
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};

View File

@ -154,7 +154,7 @@ export default {
},
getWorkSpaceList() {
this.$get("/workspace/list/userworkspace/" + encodeURIComponent(getCurrentUserId()), response => {
this.$get("/workspace/list/userworkspace", response => {
this.workspaceList = response.data;
});
},

View File

@ -742,7 +742,7 @@ export default {
this.$refs.batchEdit.open(this.condition.selectAll ? this.total : this.$refs.table.selectRows.size);
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.$get('/user/project/member/list', response => {
this.valueArr.executor = response.data;
this.executorFilters = response.data.map(u => {
return {text: u.name, value: u.id};

View File

@ -234,7 +234,7 @@ export default {
});
},
setReviewerOptions() {
this.result = this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()},response => {
this.result = this.$get('/user/project/member/list', response => {
this.reviewerOptions = response.data;
});
},

View File

@ -1,12 +1,12 @@
import {getCurrentProjectID} from "@/common/js/utils";
import {post} from "@/common/js/ajax";
import {get} from "@/common/js/ajax";
import axios from "axios";
import {ORGANIZATION_ID, PROJECT_ID, TokenKey, WORKSPACE_ID} from "@/common/js/constants";
import {baseGet} from "@/network/base-network";
export function getProjectMember(callBack) {
return new Promise((resolve) => {
post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
get('/user/project/member/list', response => {
if (callBack) {
callBack(response.data);
}