Skip to content

Commit 45a6b13

Browse files
fuweng11wakefu
andauthored
[INLONG-12094][Manager] Fix the problem of ordinary users can create new packages (#12095)
Co-authored-by: wakefu <wakefu@tencent.com>
1 parent a5001d8 commit 45a6b13

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/ModuleController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.swagger.annotations.Api;
3131
import io.swagger.annotations.ApiImplicitParam;
3232
import io.swagger.annotations.ApiOperation;
33+
import org.apache.shiro.authz.annotation.RequiresRoles;
3334
import org.springframework.beans.factory.annotation.Autowired;
3435
import org.springframework.validation.annotation.Validated;
3536
import org.springframework.web.bind.annotation.PathVariable;
@@ -38,6 +39,8 @@
3839
import org.springframework.web.bind.annotation.RequestMethod;
3940
import org.springframework.web.bind.annotation.RestController;
4041

42+
import static org.apache.inlong.manager.pojo.user.UserRoleCode.INLONG_ADMIN;
43+
4144
/**
4245
* Inlong module control layer
4346
*/
@@ -51,13 +54,15 @@ public class ModuleController {
5154

5255
@RequestMapping(value = "/module/save", method = RequestMethod.POST)
5356
@ApiOperation(value = "Save inlong module")
57+
@RequiresRoles(INLONG_ADMIN)
5458
public Response<Integer> save(@Validated(SaveValidation.class) @RequestBody ModuleRequest request) {
5559
String operator = LoginUserUtils.getLoginUser().getName();
5660
return Response.success(moduleService.save(request, operator));
5761
}
5862

5963
@RequestMapping(value = "/module/update", method = RequestMethod.POST)
6064
@ApiOperation(value = "Update inlong module")
65+
@RequiresRoles(INLONG_ADMIN)
6166
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody ModuleRequest request) {
6267
return Response.success(moduleService.update(request, LoginUserUtils.getLoginUser().getName()));
6368
}
@@ -77,6 +82,7 @@ public Response<PageResult<ModuleResponse>> listByCondition(@RequestBody ModuleP
7782

7883
@RequestMapping(value = "/module/delete/{id}", method = RequestMethod.DELETE)
7984
@ApiOperation(value = "Delete module config")
85+
@RequiresRoles(INLONG_ADMIN)
8086
public Response<Boolean> delete(@PathVariable Integer id) {
8187
return Response.success(moduleService.delete(id, LoginUserUtils.getLoginUser().getName()));
8288
}

inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/PackageController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.swagger.annotations.Api;
3131
import io.swagger.annotations.ApiImplicitParam;
3232
import io.swagger.annotations.ApiOperation;
33+
import org.apache.shiro.authz.annotation.RequiresRoles;
3334
import org.springframework.beans.factory.annotation.Autowired;
3435
import org.springframework.validation.annotation.Validated;
3536
import org.springframework.web.bind.annotation.PathVariable;
@@ -38,6 +39,8 @@
3839
import org.springframework.web.bind.annotation.RequestMethod;
3940
import org.springframework.web.bind.annotation.RestController;
4041

42+
import static org.apache.inlong.manager.pojo.user.UserRoleCode.INLONG_ADMIN;
43+
4144
/**
4245
* Inlong package control layer
4346
*/
@@ -51,13 +54,15 @@ public class PackageController {
5154

5255
@RequestMapping(value = "/package/save", method = RequestMethod.POST)
5356
@ApiOperation(value = "Save inlong package")
57+
@RequiresRoles(INLONG_ADMIN)
5458
public Response<Integer> save(@Validated(SaveValidation.class) @RequestBody PackageRequest request) {
5559
String operator = LoginUserUtils.getLoginUser().getName();
5660
return Response.success(packageService.save(request, operator));
5761
}
5862

5963
@RequestMapping(value = "/package/update", method = RequestMethod.POST)
6064
@ApiOperation(value = "Update inlong package")
65+
@RequiresRoles(INLONG_ADMIN)
6166
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody PackageRequest request) {
6267
return Response.success(packageService.update(request, LoginUserUtils.getLoginUser().getName()));
6368
}
@@ -77,6 +82,7 @@ public Response<PageResult<PackageResponse>> listByCondition(@RequestBody Packag
7782

7883
@RequestMapping(value = "/package/delete/{id}", method = RequestMethod.DELETE)
7984
@ApiOperation(value = "Delete package config")
85+
@RequiresRoles(INLONG_ADMIN)
8086
public Response<Boolean> delete(@PathVariable Integer id) {
8187
return Response.success(packageService.delete(id, LoginUserUtils.getLoginUser().getName()));
8288
}

0 commit comments

Comments
 (0)