Skip to content

Commit

Permalink
Simplify authrozation for table config get (#11640)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie-Jiang committed Sep 21, 2023
1 parent 9bcbef8 commit a96e36e
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,14 @@ private enum SortType {
NAME, CREATIONTIME, LASTMODIFIEDTIME
}

private String listTableConfigs(String tableName, @Nullable String tableTypeStr) {
@GET
@Path("/tables/{tableName}")
@Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_TABLE_CONFIG)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Lists the table configs")
public String listTableConfigs(
@ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
@ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr) {
try {
ObjectNode ret = JsonUtils.newObjectNode();

Expand All @@ -372,22 +379,6 @@ private String listTableConfigs(String tableName, @Nullable String tableTypeStr)
}
}

@GET
@Produces(MediaType.APPLICATION_JSON)
@ManualAuthorization
@Path("/tables/{tableName}")
@ApiOperation(value = "Lists the table configs")
public String listTableConfig(
@ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
@ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr, @Context HttpHeaders httpHeaders,
@Context Request request) {
if (!_accessControlFactory.create()
.hasAccess(httpHeaders, TargetType.TABLE, tableName, Actions.Table.GET_TABLE_CONFIG)) {
throw new ControllerApplicationException(LOGGER, "Permission denied", Response.Status.FORBIDDEN);
}
return listTableConfigs(tableName, tableTypeStr);
}

@DELETE
@Path("/tables/{tableName}")
@Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.DELETE_TABLE)
Expand Down

0 comments on commit a96e36e

Please sign in to comment.