Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fixed the permission issue on the task details page #4023

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -77,7 +78,19 @@ public RestResponse permissionAction(ProceedingJoinPoint joinPoint) throws Throw
"Permission denied, operations can only be performed with the permissions of the currently logged-in user.");

// 2) check team
Long teamId = getId(joinPoint, methodSignature, permission.team());
Long teamId = null;
try {
teamId = getId(joinPoint, methodSignature, permission.team());
} catch (SpelEvaluationException e) {
try {
Long appId = getId(joinPoint, methodSignature, permission.app());
Application app = applicationManageService.getById(appId);
teamId = app.getTeamId();
} catch (SpelEvaluationException e1) {
log.error(
"Failed to get teamId from permission annotation, please check the annotation configuration.");
}
}
if (teamId != null) {
Member member = memberService.getByTeamIdUserName(teamId, currentUser.getUsername());
ApiAlertException.throwIfTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public RestResponse readConf(Application app) throws IOException {

@PostMapping("main")
@Permission(app = "#app.id", team = "#app.teamId")
public RestResponse getMain(Application application) {
String mainClass = applicationInfoService.getMain(application);
public RestResponse getMain(Application app) {
String mainClass = applicationInfoService.getMain(app);
return RestResponse.success(mainClass);
}

Expand All @@ -215,16 +215,16 @@ public RestResponse backups(ApplicationBackUp backUp, RestRequest request) {
}

@PostMapping("opt_log")
@Permission(app = "#log.appId", team = "#log.teamId")
@Permission(app = "#applicationLog.appId")
public RestResponse log(ApplicationLog applicationLog, RestRequest request) {
IPage<ApplicationLog> applicationList = applicationLogService.getPage(applicationLog, request);
return RestResponse.success(applicationList);
}

@Permission(app = "#log.appId", team = "#log.teamId")
@Permission(app = "#appId")
@PostMapping("delete/opt_log")
@RequiresPermissions("app:delete")
public RestResponse deleteLog(Long id) {
public RestResponse deleteLog(Long id, Long appId) {
Boolean deleted = applicationLogService.removeById(id);
return RestResponse.success(deleted);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ export function fetchOptionLog(data) {
return defHttp.post({ url: APP_API.OPTION_LOG, data });
}

export function fetchDeleteOperationLog(id: string) {
return defHttp.post({ url: APP_API.DELETE_LOG, data: { id } });
export function fetchDeleteOperationLog(appId: string, id: string) {
return defHttp.post({ url: APP_API.DELETE_LOG, data: { appId, id } });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
}

async function handleDeleteOperationLog(record: Recordable) {
await fetchDeleteOperationLog(record.id);
await fetchDeleteOperationLog(record.appId, record.id);
await reloadOperationLog();
}

Expand Down
Loading