mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 11:13:43 +08:00
fix(workspace): return 403 instead of 500 for cross-workspace access
This commit is contained in:
parent
0a57cb3358
commit
651d53050e
@ -139,7 +139,7 @@ public class AgentBindingController {
|
||||
}
|
||||
long requestedWs = headerWorkspaceId != null ? headerWorkspaceId : 1L;
|
||||
if (agent.getWorkspaceId() != null && !agent.getWorkspaceId().equals(requestedWs)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "资源不属于当前工作区");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "资源不属于当前工作区");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ public class AgentController {
|
||||
private void verifyResourceWorkspace(Long resourceWorkspaceId, Long headerWorkspaceId) {
|
||||
long requestedWs = headerWorkspaceId != null ? headerWorkspaceId : 1L;
|
||||
if (resourceWorkspaceId != null && !resourceWorkspaceId.equals(requestedWs)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "资源不属于当前工作区");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "资源不属于当前工作区");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +236,7 @@ public class ChannelController {
|
||||
private void verifyResourceWorkspace(Long resourceWorkspaceId, Long headerWorkspaceId) {
|
||||
long requestedWs = headerWorkspaceId != null ? headerWorkspaceId : 1L;
|
||||
if (resourceWorkspaceId != null && !resourceWorkspaceId.equals(requestedWs)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "资源不属于当前工作区");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "资源不属于当前工作区");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class DashboardController {
|
||||
if (job != null && job.getWorkspaceId() != null) {
|
||||
long wsId = workspaceId != null ? workspaceId : 1L;
|
||||
if (!job.getWorkspaceId().equals(wsId)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "资源不属于当前工作区");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "资源不属于当前工作区");
|
||||
}
|
||||
}
|
||||
return R.ok(cronJobRunService.listByJobId(cronJobId, Math.min(limit, 100)));
|
||||
|
||||
@ -622,7 +622,7 @@ public class WikiController {
|
||||
}
|
||||
long wsId = headerWorkspaceId != null ? headerWorkspaceId : 1L;
|
||||
if (kb.getWorkspaceId() != null && !kb.getWorkspaceId().equals(wsId)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "资源不属于当前工作区");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "资源不属于当前工作区");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,14 +263,14 @@ public class WikiTransformationController {
|
||||
}
|
||||
long wsId = workspaceId != null ? workspaceId : 1L;
|
||||
if (kb.getWorkspaceId() != null && !kb.getWorkspaceId().equals(wsId)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "Resource does not belong to current workspace");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "Resource does not belong to current workspace");
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyTemplateWorkspace(WikiTransformationEntity t, Long workspaceId) {
|
||||
long wsId = workspaceId != null ? workspaceId : 1L;
|
||||
if (t.getWorkspaceId() != null && !t.getWorkspaceId().equals(wsId)) {
|
||||
throw new MateClawException("err.common.wrong_workspace", "Resource does not belong to current workspace");
|
||||
throw new MateClawException("err.common.wrong_workspace", 403, "Resource does not belong to current workspace");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user